public void GraphXmlSerialization() { var root = new Node { Name = "root" }; var childA = new Node { Name = "a" }; var childB = new Node { Name = "b" }; var subchildAA = new Node { Name = "a.a" }; root.Children.AddLast(childA); root.Children.AddLast(childB); childA.Children.AddLast(subchildAA); var sb = new StringBuilder(); using (var xwriter = XmlWriter.Create(sb, null)) { xwriter.WriteStartElement("test"); var writer = new XmlGraphWriter(xwriter, new AssemblyTypeResolver(Assembly.GetExecutingAssembly())); root.Serialize(writer); xwriter.WriteEndElement(); } Assert.AreEqual( GraphXML, sb.ToString() ); }