diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-01-09 20:38:04 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2009-01-09 20:38:04 -0800 |
commit | b04267156e728fa5833718cc7905f5d8de0fd895 (patch) | |
tree | 939c07a4a4258dc12eb20c3f8eb7877fcf455fdc | |
parent | 023d15a47a0f38d35d372486d9019e22a36b9154 (diff) | |
download | DotNetOpenAuth-b04267156e728fa5833718cc7905f5d8de0fd895.zip DotNetOpenAuth-b04267156e728fa5833718cc7905f5d8de0fd895.tar.gz DotNetOpenAuth-b04267156e728fa5833718cc7905f5d8de0fd895.tar.bz2 |
Fixed Util.ToStringDeferred rendering of empty, multiline lists.
-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();
|