public void CanDelete() { repo = new OrderTestRepository(); Orders order = new Orders() { OrderNumber = 2 }; repo.DeleteOrder(order); List <Orders> orders = repo.LoadOrders(date); Assert.AreEqual(1, orders.Count); Orders check = orders.FirstOrDefault(o => o.OrderNumber == 1); Assert.AreEqual(1, check.OrderNumber); Assert.AreEqual("Wise", check.CustomerName); Assert.AreEqual("OH", check.State); Assert.AreEqual(6.25, check.TaxRate); Assert.AreEqual("Wood", check.ProductType); Assert.AreEqual(100, check.Area); Assert.AreEqual(5.15, check.CostPerSquareFoot); Assert.AreEqual(4.75, check.LaborCostPerSquareFoot); Assert.AreEqual(515.00, check.MaterialCost); Assert.AreEqual(475, check.LaborCost); Assert.AreEqual(61.88, check.Tax); Assert.AreEqual(1051.88, check.Total); repo.CreateOrder(date, order); }
public void CanEdit() { repo = new OrderTestRepository(); List <Orders> orders = repo.LoadOrders(date); Orders order = orders[0]; order.CustomerName = "Tom"; order.State = "IN"; repo.UpdateOrder(order); Assert.AreEqual(2, orders.Count); orders = repo.LoadOrders(date); Orders check = orders.FirstOrDefault(o => o.OrderNumber == 1); Assert.AreEqual(1, check.OrderNumber); Assert.AreEqual("Tom", check.CustomerName); Assert.AreEqual("IN", check.State); Assert.AreEqual(6.25, check.TaxRate); Assert.AreEqual("Wood", check.ProductType); Assert.AreEqual(100, check.Area); Assert.AreEqual(5.15, check.CostPerSquareFoot); Assert.AreEqual(4.75, check.LaborCostPerSquareFoot); Assert.AreEqual(515.00, check.MaterialCost); Assert.AreEqual(475, check.LaborCost); Assert.AreEqual(61.88, check.Tax); Assert.AreEqual(1051.88, check.Total); }
public void CanAddOrderTest() { OrderTestRepository repo = new OrderTestRepository(); Order newOrder = new Order(); newOrder.OrderNumber = 2; newOrder.CustomerName = "Alan Galloway"; newOrder.State = "Kentucky"; newOrder.TaxRate = 6M; newOrder.ProductType = "Wood"; newOrder.Area = 10M; newOrder.CostPerSquareFoot = 5.15M; newOrder.LaborCostPerSquareFoot = 4.75M; newOrder.MaterialCost = (10 * 5.15M); newOrder.LaborCost = (10 * 4.75M); newOrder.Tax = (((10 * 5.15M) + (10 * 4.75M)) * (6 / 100M)); newOrder.Total = ((10 * 5.15M) + (10 * 4.75M) + (((10 * 5.15M) + (10 * 4.75M)) * (6 / 100))); newOrder.OrderDate = DateTime.Today; repo.Add(newOrder); List <Order> orders = repo.List(DateTime.Today); Order check = orders[1]; Assert.AreEqual("Alan Galloway", check.CustomerName); Assert.AreEqual("Kentucky", check.State); Assert.AreEqual(6M, check.TaxRate); Assert.AreEqual("Wood", check.ProductType); }
public void CanAddOrderTest() { Manager manager = ManagerFactory.Create(); OrderTestRepository repo = new OrderTestRepository(); Order orderToAdd = new Order() { OrderDate = DateTime.Parse("07/01/2019"), CustomerName = "James", State = "MI", TaxRate = 5.75M, ProductType = "Carpet", Area = 100.00M, CostPerSquareFoot = 2.25M, LaborCostPerSquareFoot = 2.10M }; Order order = manager.CreateNewOrder(orderToAdd.OrderDate, orderToAdd.CustomerName, orderToAdd.State, orderToAdd.ProductType, orderToAdd.Area); manager.AddOrder(order); List <Order> orderList = repo.LoadOrders(order.OrderDate); Assert.AreEqual(225, order.MaterialCost); Assert.AreEqual(3, orderList.Count()); }
public void AddOrder(int OrderNumber, string name, string state, string ProductType, decimal Area, bool expectedResults) { //should output to 1 for true but keeps throwing exception because not bool OrderTestRepository repo = new OrderTestRepository(); Order Order = new Order(); Order.OrderNumber = OrderNumber; Order.CustomerName = name; Order.State = state; Order.Area = Area; Order.ProductType = ProductType; AddOrderResponse response = new AddOrderResponse(); response.Order = repo.SaveOrder(Order, DateTime.Today); if (response.Order.Area == 1) { response.Sucess = true; } var response2 = repo.SaveOrder(response.Order, DateTime.Today); Assert.AreEqual(expectedResults, response.Sucess); }
public static IOrderRepository CreateOrderRepo() { IOrderRepository repo; string mode = ConfigurationManager.AppSettings["Mode"].ToString(); switch (mode) { case "Test": repo = new OrderTestRepository(); break; case "Prod": repo = new OrderProdRepository(); break; default: throw new Exception("Mode Value in App Config is not Valid."); } return(repo); }
public void CanLoadList()//run all together than wont passed { repo = new OrderTestRepository(); List <Orders> orders = repo.LoadOrders(date); Assert.AreEqual(2, orders.Count); Orders check = orders.FirstOrDefault(o => o.OrderNumber == 1); Assert.AreEqual(1, check.OrderNumber); Assert.AreEqual("Wise", check.CustomerName); Assert.AreEqual("OH", check.State); Assert.AreEqual(6.25, check.TaxRate); Assert.AreEqual("Wood", check.ProductType); Assert.AreEqual(100, check.Area); Assert.AreEqual(5.15, check.CostPerSquareFoot); Assert.AreEqual(4.75, check.LaborCostPerSquareFoot); Assert.AreEqual(515.00, check.MaterialCost); Assert.AreEqual(475, check.LaborCost); Assert.AreEqual(61.88, check.Tax); Assert.AreEqual(1051.88, check.Total); }