Exemplo n.º 1
0
        public void TestLoadFromXmlA()
        {
            var xml = @"<artist>
  <personal_data>
    <given_name>Hugh</given_name>
    <family_name>Laurie</family_name>
  </personal_data>
</artist>";

            PersonA person = XmlSerialization.LoadFromXml <PersonA>(xml);

            Assert.AreEqual("Hugh", person.FirstName);
            Assert.AreEqual("Laurie", person.LastName);
        }
Exemplo n.º 2
0
        public void TestToXmlA()
        {
            PersonA person = new PersonA()
            {
                FirstName = "Hugh",
                LastName  = "Laurie"
            };

            string xml = person.ToXml();

            var doc = XDocument.Parse(xml);

            var elementFirstName = doc.XPathSelectElement("/artist/personal_data/given_name");

            Assert.AreEqual("Hugh", elementFirstName.Value);

            var elementLastName = doc.XPathSelectElement("/artist/personal_data/family_name");

            Assert.AreEqual("Laurie", elementLastName.Value);
        }