diff --git a/Gu.Xml.Tests/XmlTests.ReferenceLoops.cs b/Gu.Xml.Tests/XmlTests.ReferenceLoops.cs
index 4a72755..fad2dc5 100644
--- a/Gu.Xml.Tests/XmlTests.ReferenceLoops.cs
+++ b/Gu.Xml.Tests/XmlTests.ReferenceLoops.cs
@@ -1,4 +1,5 @@
-namespace Gu.Xml.Tests
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+namespace Gu.Xml.Tests
{
using System;
using NUnit.Framework;
@@ -29,7 +30,7 @@ public void LinkedListRootOneNode()
}
[Test]
- public void Infinite()
+ public void LinkedListInfinite()
{
var list = new LinkedList();
list.Next = list;
@@ -37,10 +38,49 @@ public void Infinite()
Assert.AreEqual("Indent level > 1000, reference loop?", exception.Message);
}
+ [Test]
+ public void ParentNoChild()
+ {
+ var actual = Xml.Serialize(new Parent());
+ var expected = "" + Environment.NewLine +
+ "";
+ Assert.AreEqual(expected, actual);
+ }
+
+ [Test]
+ public void ParentChild()
+ {
+ var actual = Xml.Serialize(new Parent { Child = new Child() });
+ var expected = "" + Environment.NewLine +
+ "" + Environment.NewLine +
+ " " + Environment.NewLine +
+ "";
+ Assert.AreEqual(expected, actual);
+ }
+
+ [Test]
+ public void ParentChildInfinite()
+ {
+ var parent = new Parent { Child = new Child() };
+ parent.Child.Parent = parent;
+ var exception = Assert.Throws(() => Xml.Serialize(parent));
+ Assert.AreEqual("Indent level > 1000, reference loop?", exception.Message);
+ }
+
public class LinkedList
{
public LinkedList Next { get; set; }
}
+
+ public class Parent
+ {
+ public Child Child { get; set; }
+ }
+
+ public class Child
+ {
+ public Parent Parent { get; set; }
+ }
}
}
}
\ No newline at end of file