public void ExportID1Order() { var order = new AllfleXML.ID1Order.ID1Order { CUSTNMBR = "testing", CSTPONBR = "test1234", OrderDelivery = new OrderDelivery { ShipToName = "Customer", ADDRESS1 = "123 ABC St.", ADDRESS2 = "SUITE 100", CITY = "Dallas", STATE = "TX", ZIPCODE = "76021" }, OrderLines = new List <OrderLine> { new OrderLine { ITEMNMBR = "APP-UTT", QTYORDER = 60 } } }; var doc = AllfleXML.ID1Order.Parser.Export(order); Assert.IsNotNull(doc); var isValid = AllfleXML.ID1Order.Parser.Validate(doc); Assert.IsTrue(isValid); }
public static XDocument Export(this ID1Order order) { var result = new XDocument(); using (var writer = result.CreateWriter()) { var serializer = new XmlSerializer(order.GetType()); serializer.Serialize(writer, order); } return(result); }
public void SaveID1Order() { var order = new AllfleXML.ID1Order.ID1Order { CUSTNMBR = "testing", CSTPONBR = "test1234", OrderDelivery = new OrderDelivery { ShipToName = "Customer", ADDRESS1 = "123 ABC St.", ADDRESS2 = "SUITE 100", CITY = "Dallas", STATE = "TX", ZIPCODE = "76021" }, OrderLines = new List <OrderLine> { new OrderLine { ITEMNMBR = "APP-UTT", QTYORDER = 60 } } }; var doc = AllfleXML.ID1Order.Parser.Export(order); Assert.IsNotNull(doc); var isValid1 = AllfleXML.ID1Order.Parser.Validate(doc); Assert.IsTrue(isValid1); const string fileName = "testid1Order.xml"; order.Save(fileName); Assert.IsTrue(File.Exists(fileName)); var isValid2 = AllfleXML.ID1Order.Parser.Validate(fileName); Assert.IsTrue(isValid2); var tmp = AllfleXML.ID1Order.Parser.Import(fileName); Assert.IsNotNull(tmp); Assert.IsTrue(tmp.ID1Order.Any()); Assert.IsTrue(tmp.ID1Order.Select(o => o.OrderLines.Any()).All(o => o)); File.Delete(fileName); Assert.IsFalse(File.Exists(fileName)); }
public static void Save(this ID1Order order, string xmlFilePath) { var doc = Export(order); doc.Save(xmlFilePath); }