Commit 05b4d6ed authored by sovietmagic's avatar sovietmagic
Browse files

SvgTextBase Text property setter resets Node collection to have single content...

SvgTextBase Text property setter resets Node collection to have single content node with provided text.
parent 3c3e5608
...@@ -26,7 +26,16 @@ namespace Svg ...@@ -26,7 +26,16 @@ namespace Svg
public virtual string Text public virtual string Text
{ {
get { return base.Content; } get { return base.Content; }
set { base.Content = value; this.IsPathDirty = true; this.Content = value; } set {
Nodes.Clear();
Children.Clear();
if(value != null)
{
Nodes.Add(new SvgContentNode { Content = value });
}
this.IsPathDirty = true;
Content = value;
}
} }
/// <summary> /// <summary>
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
<Compile Include="SmallEmbeddingImageTest.cs" /> <Compile Include="SmallEmbeddingImageTest.cs" />
<Compile Include="SvgPointCollectionTests.cs" /> <Compile Include="SvgPointCollectionTests.cs" />
<Compile Include="SvgTestHelper.cs" /> <Compile Include="SvgTestHelper.cs" />
<Compile Include="SvgTextTests.cs" />
<Compile Include="SvgTextElementDeepCopyTest.cs" /> <Compile Include="SvgTextElementDeepCopyTest.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
namespace Svg.UnitTests
{
[TestClass]
public class SvgTextTests
{
[TestMethod]
public void TextPropertyAffectsSvgOutput()
{
var document = new SvgDocument();
document.Children.Add(new SvgText { Text = "test1" });
using(var stream = new MemoryStream())
{
document.Write(stream);
stream.Position = 0;
var xmlDoc = new XmlDocument();
xmlDoc.Load(stream);
Assert.AreEqual("test1", xmlDoc.DocumentElement.FirstChild.InnerText);
}
}
}
}
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