diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj | 1 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Test/UtilTests.cs | 24 | ||||
-rw-r--r-- | src/DotNetOpenAuth/Util.cs | 4 |
3 files changed, 27 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj index 2b8b857..181cea3 100644 --- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj +++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj @@ -148,6 +148,7 @@ <Compile Include="TestBase.cs" /> <Compile Include="TestUtilities.cs" /> <Compile Include="UriUtilTests.cs" /> + <Compile Include="UtilTests.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\DotNetOpenAuth\DotNetOpenAuth.csproj"> diff --git a/src/DotNetOpenAuth.Test/UtilTests.cs b/src/DotNetOpenAuth.Test/UtilTests.cs new file mode 100644 index 0000000..5ea4d0c --- /dev/null +++ b/src/DotNetOpenAuth.Test/UtilTests.cs @@ -0,0 +1,24 @@ +//----------------------------------------------------------------------- +// <copyright file="UtilTests.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Test { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class UtilTests { + /// <summary> + /// Verifies ToStringDeferred generates a reasonable string for an empty, multi-line list. + /// </summary> + [TestMethod] + public void ToStringDeferredEmptyMultiLine() { + Assert.AreEqual("[]", Util.ToStringDeferred(Enumerable.Empty<string>(), true).ToString()); + } + } +} diff --git a/src/DotNetOpenAuth/Util.cs b/src/DotNetOpenAuth/Util.cs index e2ad5f7..8b4d011 100644 --- a/src/DotNetOpenAuth/Util.cs +++ b/src/DotNetOpenAuth/Util.cs @@ -160,10 +160,10 @@ namespace DotNetOpenAuth { }
sb.AppendLine("}, {");
}
- if (sb.Length > 2) { // if anything was in the enumeration
+ if (sb.Length > 2 + Environment.NewLine.Length) { // if anything was in the enumeration
sb.Length -= 2 + Environment.NewLine.Length; // trim off the last ", {\r\n"
} else {
- sb.Length -= 1; // trim off the opening {
+ sb.Length -= 1 + Environment.NewLine.Length; // trim off the opening {
}
sb.Append("]");
return sb.ToString();
|