public void TestLoadFromXmlD() { var xml = @"<name last='Laurie'>Hugh</name>"; PersonD person = XmlSerialization.LoadFromXml <PersonD>(xml); Assert.AreEqual("Hugh", person.FirstName); Assert.AreEqual("Laurie", person.LastName); }
public void TestToXmlD() { PersonD person = new PersonD() { FirstName = "Hugh", LastName = "Laurie" }; string xml = person.ToXml(); var doc = XDocument.Parse(xml); var elementFirstName = doc.XPathSelectElement("/name"); Assert.AreEqual("Hugh", elementFirstName.Value); var attributeLastName = doc.XPathSelectElement("/name").Attribute("last"); Assert.AreEqual("Laurie", attributeLastName.Value); }