public void TestAddMethod() { OrdersList ol = new OrdersList(); ol.AddOrder(new Order()); Assert.AreEqual(ol.orders.Count, 1); }
public void TestFindMethod() { OrdersList ol = new OrdersList(); Order o = new Order(); ol.AddOrder(o); Assert.AreEqual(ol.Find(or => or == o), o); }
public void TestDeleteMethod() { OrdersList ol = new OrdersList(); Order o = new Order(); ol.AddOrder(o); ol.DeleteOrder(o); Assert.AreEqual(ol.orders.Count, 0); }
public static OrdersList Parse(XmlNodeList customerOrderNodeList, ProductClassList productsList) { OrdersList customerOrderList = new OrdersList(); foreach (XmlNode customerOrderNode in customerOrderNodeList)//orders level { Order order = new Order(Order.OrderTypeEnum.CustomerOrder); Customer customer = new Customer(); foreach (XmlNode customerOrderParameter in customerOrderNode)//order parts level { XMLCustomerOrderFields XMLcustomerOrderField = (XMLCustomerOrderFields)Enum.Parse(typeof(XMLCustomerOrderFields), customerOrderParameter.Name, true); switch (XMLcustomerOrderField) { case XMLCustomerOrderFields.CustomerName: customer.Name = customerOrderParameter.InnerText; break; case XMLCustomerOrderFields.CustomerID: customer.ID = customerOrderParameter.InnerText; break; case XMLCustomerOrderFields.CustomerOrderID: order.OrderID = customerOrderParameter.InnerText; break; case XMLCustomerOrderFields.CustomerOrderDate: order.OrderDate = DateTime.Parse(customerOrderParameter.InnerText); break; case XMLCustomerOrderFields.CustomerOrderDeliveryDate: order.OrderDeliveryDate = DateTime.Parse(customerOrderParameter.InnerText); break; case XMLCustomerOrderFields.CustomerOrder_Status: order.OrderStatus = (Order.OrderStatusEnum)Enum.Parse(typeof(Order.OrderStatusEnum), customerOrderParameter.InnerText, true); break; case XMLCustomerOrderFields.CustomerOrderProductsList: order.OrderProductsList = getOrderProductsList(customerOrderParameter, productsList); break; default: break; } //end switch } // end order parts level order.Person = customer; customerOrderList.AddOrder(order); }//end orders level return(customerOrderList); }
public static OrdersList Parse(XmlNodeList OrderNodeList, InitDataLoad initDataLoad, Order.OrderTypeEnum orderType) { ProductClassList productsList = initDataLoad.MetaData.ProductsMetaData; SuppliersList SuppliersMetaData = initDataLoad.MetaData.SuppliersMetaData; OrdersList orderList = new OrdersList(); foreach (XmlNode customerOrderNode in OrderNodeList)//orders level { Order order = new Order(orderType); Customer customer = new Customer(); foreach (XmlNode orderParameter in customerOrderNode)//order parts level { XMLOrderFields XMLcustomerOrderField = (XMLOrderFields)Enum.Parse(typeof(XMLOrderFields), orderParameter.Name, true); switch (XMLcustomerOrderField) { case XMLOrderFields.PersonName: customer.Name = orderParameter.InnerText; break; case XMLOrderFields.PersonID: customer.ID = orderParameter.InnerText; break; case XMLOrderFields.OrderID: order.OrderID = orderParameter.InnerText; break; case XMLOrderFields.OrderDate: order.OrderDate = DateTime.Parse(orderParameter.InnerText); break; case XMLOrderFields.OrderDeliveryDate: order.OrderDeliveryDate = DateTime.Parse(orderParameter.InnerText); break; case XMLOrderFields.Order_Status: order.OrderStatus = (Order.OrderStatusEnum)Enum.Parse(typeof(Order.OrderStatusEnum), orderParameter.InnerText, true); break; case XMLOrderFields.OrderProductsList: order.OrderProductsList = getOrderProductsList(orderParameter, productsList); break; default: break; } //end switch } // end order parts level if (orderType == Order.OrderTypeEnum.CustomerOrder) { order.Person = customer; } else { order.Person = SuppliersMetaData.GetSupplier(customer.ID); } orderList.AddOrder(order); }//end orders level return(orderList); }