public void TestCreateOrderFromXML2() { _logger.LogInformation("Testing CreateOrderFromXML 2nd Version"); string time = DateTime.Now.ToString(); string location = "TestMethod9"; string fileName = "c:\\src\\data\\testcontext2.xml"; string fileOrder = "c:\\src\\data\\testorder2.xml"; var dataFactory = new XMLDataFactory(); Context context = dataFactory.MakeXMLContext(); context.Location = location; context.Method = "UnitMethod9"; context.Time = time; context.RequestType = 3; XMLSupport.Models.Order order = dataFactory.MakeXMLOrder(11001, 1); Customer customer = dataFactory.MakeXMLCustomer(1002, "John Doe", "1111 Parkway", "My City", "NC", "28111"); order.CustomerObj = customer; List <XMLSupport.Models.Item> items = dataFactory.MakeXMLItemList(); XMLSupport.Models.Item item = dataFactory.MakeXMLItem(9001, "Test Item 1", 2.99, 1, "Test1.png", 1000); items.Add(item); item = dataFactory.MakeXMLItem(9002, "Test Item 2", 2.99, 1, "Test2.png", 1000); items.Add(item); order.Items = items; context.InOrder = order; var serializer = new Serializer(); XmlSerializer xmlSerializer = new XmlSerializer(typeof(Context)); bool result = serializer.SerializeToFile(xmlSerializer, context, fileName); if (result == true) { _logger.LogInformation("successfully serialize context to file"); } else { _logger.LogWarning("failed to serialize context to file"); } XmlSerializer xmlSerializer2 = new XmlSerializer(typeof(XMLSupport.Models.Order)); result = serializer.SerializeToFile(xmlSerializer2, order, fileOrder); if (result == true) { _logger.LogInformation("successfully serialize order to file"); } else { _logger.LogWarning("failed to serialize order to file"); } _XMLClient.IsTestObject = true; result = _XMLClient.CreateOrderFromXML(context.InOrder, time, location); if (result == true) { _logger.LogInformation("successfully ran CreateOrderFromXML"); } else { _logger.LogWarning("failed Logto run CreateOrderFromXML"); } // clean up test objects inserted result = _XMLClient.CleanUpTestOrders(); if (result == true) { _logger.LogInformation("Successfully clean up test items"); } else { _logger.LogWarning("Failed to clean up test items"); } }
public void TestCreateOrderFromXML() { _logger.LogInformation("Testing CreateOrderFromXML"); string fileName = "c:\\src\\data\\testorder.xml"; var dataFactory = new XMLDataFactory(); XMLSupport.Models.Order order = dataFactory.MakeXMLOrder(11001, 1); Customer customer = dataFactory.MakeXMLCustomer(1002, "John Doe", "1111 Parkway", "My City", "NC", "28111"); order.CustomerObj = customer; List <XMLSupport.Models.Item> items = dataFactory.MakeXMLItemList(); XMLSupport.Models.Item item = dataFactory.MakeXMLItem(9001, "Test Item 1", 2.99, 1, "Test1.png", 1000); items.Add(item); item = dataFactory.MakeXMLItem(9002, "Test Item 2", 2.99, 1, "Test2.png", 1000); items.Add(item); order.Items = items; order.BeforeTax = 5.98; order.Tax = 0.17; order.Shipping = 0.00; order.Tip = 2.00; order.Total = 8.15; string time = DateTime.Now.ToString(); string location = "TestMethod7"; var serializer = new Serializer(); XmlSerializer xmlSerializer = new XmlSerializer(typeof(XMLSupport.Models.Order)); bool result = serializer.SerializeToFile(xmlSerializer, order, fileName); if (result == true) { _logger.LogInformation("successfully serialize to file"); } else { _logger.LogWarning("failed to serialize to file"); } _XMLClient.IsTestObject = true; result = _XMLClient.CreateOrderFromXML(order, time, location); if (result == true) { _logger.LogInformation("successfully ran CreateOrderFromXML"); } else { _logger.LogWarning("failed to run CreateOrderFromXML"); } // clean up test objects inserted result = _XMLClient.CleanUpTestOrders(); if (result == true) { _logger.LogInformation("Successfully clean up test items"); } else { _logger.LogWarning("Failed to clean up test items"); } }