public void TestLoadFromXmlB() { var xml = @"<person profession='artist' country='UK'> <personal_data> <given_name>Hugh</given_name> <family_name>Laurie</family_name> </personal_data> </person>"; PersonB person = XmlSerialization.LoadFromXml <PersonB>(xml); Assert.AreEqual("Hugh", person.FirstName); Assert.AreEqual("Laurie", person.LastName); }
public void TestToXmlB() { PersonB person = new PersonB() { FirstName = "Hugh", LastName = "Laurie" }; string xml = person.ToXml(); var doc = XDocument.Parse(xml); var elementFirstName = doc.XPathSelectElement("/person[@profession='artist' and @country='UK']/personal_data/given_name"); Assert.AreEqual("Hugh", elementFirstName.Value); var elementLastName = doc.XPathSelectElement("/person[@profession='artist' and @country='UK']/personal_data/family_name"); Assert.AreEqual("Laurie", elementLastName.Value); }