Commit 18c1b3bf authored by Tebjan Halm's avatar Tebjan Halm Committed by GitHub
Browse files

Merge pull request #251 from sovietmagic/master

SvgPointCollection ToString method fix
parents 6fa3f29a c5369109
......@@ -15,13 +15,22 @@ namespace Svg
{
public override string ToString()
{
string ret = "";
foreach (var unit in this)
var builder = new StringBuilder();
for (var i = 0; i < Count; i += 2)
{
ret += unit.ToString() + " ";
if (i + 1 < Count)
{
if (i > 1)
{
builder.Append(" ");
}
// we don't need unit type
builder.Append(this[i].Value.ToString(CultureInfo.InvariantCulture));
builder.Append(",");
builder.Append(this[i + 1].Value.ToString(CultureInfo.InvariantCulture));
}
}
return ret;
return builder.ToString();
}
}
......
......@@ -62,6 +62,7 @@
<Compile Include="PrivateFontsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SmallEmbeddingImageTest.cs" />
<Compile Include="SvgPointCollectionTests.cs" />
<Compile Include="SvgTestHelper.cs" />
</ItemGroup>
<ItemGroup>
......
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Svg.UnitTests {
[TestClass]
public class SvgPointCollectionTests
{
[TestMethod]
public void ToStringReturnsValidString()
{
var collection = new SvgPointCollection
{
new SvgUnit(1.6f), new SvgUnit(3.2f),
new SvgUnit(1.2f), new SvgUnit(5f)
};
Assert.AreEqual("1.6,3.2 1.2,5", collection.ToString());
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment