public void ExtensibleSerializationWithOneExtension() { ExtensibleXmlGraphSerializer ser = new ExtensibleXmlGraphSerializer(); Graph g = GetTestGraph(); IXmlExtension extension = new TestExtension(); ser.RegisterExtension(extension); XDocument doc = ser.Serialize(g); Assert.IsNotNull(doc); ExtensionXmlNames extNames = new ExtensionXmlNames(); XElement extensions = doc.Root.Element(extNames.ExtensionListElement); Assert.IsNotNull(extensions); }
public void ExtensibleDeserialization() { ExtensibleXmlGraphSerializer ser = new ExtensibleXmlGraphSerializer(); Graph g = GetTestGraph(); IXmlExtension extension = new TestExtension(); ser.RegisterExtension(extension); XDocument doc = ser.Serialize(g); string path = Path.GetTempFileName(); doc.Save(path); Assert.IsTrue(File.Exists(path)); ExtensibleXmlGraphDeserializer extDeser = new ExtensibleXmlGraphDeserializer(); var result = extDeser.Load(path); Assert.IsNotNull(result); Assert.IsNotNull(result.Graph); Assert.AreEqual(1, result.Extensions.Count); }