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

Merge pull request #262 from sovietmagic/master

Proper SvgTextBase.Text property setter behaviour
parents 3c3e5608 05b4d6ed
......@@ -26,7 +26,16 @@ namespace Svg
public virtual string Text
{
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>
......
......@@ -64,6 +64,7 @@
<Compile Include="SmallEmbeddingImageTest.cs" />
<Compile Include="SvgPointCollectionTests.cs" />
<Compile Include="SvgTestHelper.cs" />
<Compile Include="SvgTextTests.cs" />
<Compile Include="SvgTextElementDeepCopyTest.cs" />
</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