public void required_notfound() { var doc = XDocument.Parse("<?xml version='1.0' encoding='utf-16'?><Customer xmlns='uis.org'><Name></Name><Age>32</Age></Customer>"); var map = new CustomerMap(); Customer customer; using (var reader = doc.CreateReader()) { customer = map.ReadXml(reader, e => Console.WriteLine(e.Message)); } Assert.AreEqual("", customer.Name); Assert.AreEqual(32, customer.Age); }
public void ReadCustmer() { var map = new CustomerMap(); var xml = new StringReader(@"<?xml version='1.0' encoding='utf-16' ?><Customer xmlns='uis.org'><Name>John</Name><Age>32</Age></Customer>"); Customer customer; using (var reader = XmlReader.Create(xml)) { customer = map.ReadXml(reader); } Assert.AreEqual("John", customer.Name); Assert.AreEqual(32, customer.Age); }