public void CreateOrdersTest() { List <string> errors = new List <string>(); Orders order = new Orders(); order.order_id = 1; order.customer_id = 1; order.grand_total = 0; order.tax_total = 0; order.subtotal = order.grand_total + order.tax_total; order.date_created = new DateTime(); order.condition = 'a'; int id = DALOrders.CreateOrder(order, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreNotEqual(-1, id); Orders temp = null; temp = DALOrders.ReadOrder(id, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(order.subtotal, temp.subtotal); Assert.AreEqual(order.customer_id, temp.customer_id); Assert.AreEqual(order.grand_total, temp.grand_total); Assert.AreEqual(order.tax_total, temp.tax_total); Assert.AreEqual(order.condition, temp.condition); }
public void CreateOrderItemTest() { List <string> errors = new List <string>(); //create new order first to get a new order id Orders order = new Orders(); order.order_id = 1; order.customer_id = 1; order.grand_total = 0; order.tax_total = 0; order.subtotal = order.grand_total + order.tax_total; order.date_created = new DateTime(); order.condition = 'a'; int id = DALOrders.CreateOrder(order, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreNotEqual(-1, id); //now safe to create new order item Order_item oi = new Order_item(); order.order_id = id; oi.order_id = id; oi.product_variation_id = 10; oi.quantity = 100; oi.sale_price = 15.8F; oi.tax = 0.0875F; int result = DALOrder_item.CreateOrderItem(order, oi, ref errors); Assert.AreEqual(1, result); Assert.AreEqual(0, errors.Count); Order_item temp = DALOrder_item.ReadOrderItem(id, 10, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(temp.order_id, id); Assert.AreEqual(temp.product_variation_id, 10); Assert.AreEqual(temp.quantity, oi.quantity); Assert.AreEqual(temp.sale_price, oi.sale_price); Assert.AreEqual(temp.tax, oi.tax); Assert.AreEqual(temp.condition, 'a'); Orders temp2 = DALOrders.ReadOrder(id, ref errors); Assert.AreEqual(1580, temp2.subtotal); Assert.AreEqual(138.25, temp2.tax_total); Assert.AreEqual(1718.25, temp2.grand_total); Assert.AreEqual('a', temp.condition); }
public static Orders ReadOrder(int o, ref List <string> errors) { if (o <= 0) { errors.Add("Invalid order id"); } if (errors.Count > 0) { return(null); } return(DALOrders.ReadOrder(o, ref errors)); }
public void ReadOrdersTest() { List <string> errors = new List <string>(); Orders temp = null; temp = DALOrders.ReadOrder(1, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(1, temp.order_id); Assert.AreEqual(545, temp.customer_id); Assert.AreEqual(2260.81F, temp.subtotal); Assert.AreEqual(2260.81F, temp.grand_total); Assert.AreEqual(0, temp.tax_total); Assert.AreEqual('a', temp.condition); }
public void UpdateOrderItemTest() { List <string> errors = new List <string>(); //update exist record Order_item oi = new Order_item(); oi.order_id = 1; oi.product_variation_id = 32; oi.quantity = 13; int result = DALOrder_item.UpdateOrderItem(oi, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(1, result); Order_item temp2 = null; temp2 = DALOrder_item.ReadOrderItem(1, 32, ref errors); Assert.AreEqual(1, temp2.order_id); Assert.AreEqual(32, temp2.product_variation_id); Assert.AreEqual(13, temp2.quantity); Assert.AreEqual(18.99F, temp2.sale_price); Assert.AreEqual(0F, temp2.tax); Assert.AreEqual('a', temp2.condition); //check subtotal, grand total, tax total update Orders temp = DALOrders.ReadOrder(1, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(2260.81F, temp.subtotal); Assert.AreEqual(545F, temp.customer_id); Assert.AreEqual(2260.81F, temp.grand_total); Assert.AreEqual(0F, temp.tax_total); Assert.AreEqual('a', temp.condition); }