public void OrderManagerEditOrderTest(DateTime date, int orderNumber, string customerName, string state, string productType, decimal area, string expectedName, string expectedState, string expectedProduct, decimal expectedArea, bool expectedResult) { TestOrderRepository testOrderRepo = new TestOrderRepository(); TestProductRepository testProductRepo = new TestProductRepository(); TestTaxRepository testTaxRepo = new TestTaxRepository(); OrderManager manager = new OrderManager(testOrderRepo, testProductRepo, testTaxRepo); DisplaySingleOrderResponse singleResponse = manager.GetOrderToEdit(date, orderNumber); Assert.AreEqual(singleResponse.Order.Date, date); Assert.AreEqual(singleResponse.Order.OrderNumber, orderNumber); Assert.AreEqual(singleResponse.Order.CustomerName, customerName); Assert.AreEqual(singleResponse.Order.State, state); Assert.AreEqual(singleResponse.Order.ProductType, productType); Assert.AreEqual(singleResponse.Order.Area, area); EditOrderResponse response = manager.EditOrder(date, orderNumber, expectedName, expectedState, expectedProduct, expectedArea); // DisplaySingleOrderResponse afterEditResponse = manager.GetOrderToEdit(date, orderNumber); if (response.Success) { testOrderRepo.UpdateThisOrder(response.Order); DisplaySingleOrderResponse afterEditResponse = manager.GetOrderToEdit(date, orderNumber); Assert.AreEqual(afterEditResponse.Order.Date, date); Assert.AreEqual(afterEditResponse.Order.OrderNumber, orderNumber); Assert.AreEqual(afterEditResponse.Order.CustomerName, expectedName); Assert.AreEqual(afterEditResponse.Order.State, expectedState); Assert.AreEqual(afterEditResponse.Order.ProductType, expectedProduct); Assert.AreEqual(afterEditResponse.Order.Area, expectedArea); } //testOrderRepo.UpdateThisOrder(response.Order); //Assert.AreEqual(expectedResult, }
public void OrderManagerAddOrderTest(DateTime date, string customerName, string state, string productType, decimal area, bool expectedResult, int expectedCount) { TestOrderRepository testOrderRepo = new TestOrderRepository(); TestProductRepository testProductRepo = new TestProductRepository(); TestTaxRepository testTaxRepo = new TestTaxRepository(); OrderManager addOrderRule = new OrderManager(testOrderRepo, testProductRepo, testTaxRepo); AddOrderResponse response = addOrderRule.BuildNewOrder(date, customerName, state, productType, area); //Order order = new Order(); //order.Date = date; //order.OrderNumber = orderNumber; //order.CustomerName = customerName; //order.State = state; //order.TaxRate = taxRate; //order.ProductType = productType; //order.Area = area; //order.CostPerSquareFoot = costPerSqFt; //order.LaborCostPerSquareFoot = laborCostPerSqFt; Assert.AreEqual(expectedResult, response.Success); if (response.Success) { testOrderRepo.CommitThisOrder(response.Order); Assert.AreEqual(expectedCount, testOrderRepo.GetAllOrdersForDate(date).Count); } }
public static OrderManager Create() { string mode = ConfigurationManager.AppSettings["Mode"].ToString(); IOrderRepository orderRepository; ITaxRepository taxRepository; IProductRepository productRepository; switch (mode) { case "Test": orderRepository = new TestOrderRepository(); taxRepository = new TestTaxRepository(); productRepository = new TestProductRepository(); return(new OrderManager(orderRepository, taxRepository, productRepository)); case "Production": orderRepository = new FileOrderRepository(); taxRepository = new TaxRepository(); productRepository = new ProductRepository(); return(new OrderManager(orderRepository, taxRepository, productRepository)); default: throw new Exception("Mode value in app config is not valid"); } }
public static FlooringProgramManager CreateFlooringProgramManager(string modeChoice) { if (modeChoice == "TEST") { IClient testClientRepo = new TestClientRepository(); IOrderRepository testOrderRepo = new TestOrderRepository(); IProducts testProdRepo = new TestProductRepository(); ITaxRate testTaxRepo = new TestTaxRepository(); return(new FlooringProgramManager(testClientRepo, testOrderRepo, testProdRepo, testTaxRepo)); } else { IClient clientRepo = new ClientRepository(); IOrderRepository orderRepo = new OrderRepository(); IProducts prodRepo = new ProductRepository(); ITaxRate taxRepo = new TaxRepository(); return(new FlooringProgramManager(clientRepo, orderRepo, prodRepo, taxRepo)); } }