Do not copy None, Inherit and NotSet at DeepCopy (#565)

* Do not copy None, Inherit and NotSet at DeepCopy.
* Add test.
This commit is contained in:
H1Gdev 2019-08-31 23:30:02 +09:00 коммит произвёл mrbean-bremen
Родитель b5a0ce7c2e
Коммит dc35216f41
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -73,6 +73,9 @@ namespace Svg
public override SvgElement DeepCopy<T>()
{
if (this == None || this == Inherit || this == NotSet)
return this;
var newObj = base.DeepCopy<T>() as SvgColourServer;
newObj.Colour = this.Colour;
return newObj;

Просмотреть файл

@ -71,6 +71,14 @@ namespace Svg.UnitTests
Assert.IsInstanceOf<T>(dest);
}
[Test]
public void TestDoNotDeepCopy()
{
Assert.AreSame(SvgPaintServer.None, SvgPaintServer.None.DeepCopy());
Assert.AreSame(SvgColourServer.Inherit, SvgColourServer.Inherit.DeepCopy());
Assert.AreSame(SvgColourServer.NotSet, SvgColourServer.NotSet.DeepCopy());
}
/// <summary>
/// Tests that the deep copy of a <see cref="SvgText"/> is done correctly where the
/// text element has contains only text and now other elements like <see cref="SvgTextSpan"/>.