public void NewLaborCostUpdatesCorrectly(string newArea, string newProductName) { OrderRepository OrderRepo = new OrderRepository(); EditOrderManager EditManager = new EditOrderManager(OrderRepo); ProductRepository ProductRepo = new ProductRepository(); //order product started with this EditManager.OrderToEdit.Product = new Product(); EditManager.OrderToEdit.Product.ProductType = "Carpet"; EditManager.OrderToEdit.Product.CostPerSquareFoot = 2.25M; EditManager.OrderToEdit.Product.LaborCostPerSquareFoot = 2.10M; EditManager.OrderToEdit.Area = 200M; EditManager.OrderToEdit.ProductType = "Carpet"; EditManager.ValidateArea(newArea); EditManager.ValidateProduct(newProductName); //this product object will be used to determine test calculations Product testProduct = ProductRepo.ProductList.Find(p => p.ProductType == newProductName); decimal testLaborCost = EditManager.NewArea * testProduct.LaborCostPerSquareFoot; EditManager.CalculateNewLaborCost(); Assert.AreEqual(EditManager.NewLaborCost, testLaborCost); //now change it -- how do I do that //user updates product }
public void ProductUpdatesIfNotNull() { string input = "Wood"; Response response = new Response(); OrderRepository OrderRepo = new OrderRepository(); EditOrderManager EditManager = new EditOrderManager(OrderRepo); EditManager.OrderToEdit.Product = new Product(); EditManager.OrderToEdit.Product.ProductType = "Carpet"; EditManager.OrderToEdit.Product.CostPerSquareFoot = 2.25M; EditManager.OrderToEdit.Product.LaborCostPerSquareFoot = 2.10M; EditManager.OrderToEdit.ProductType = "Carpet"; response = EditManager.ValidateProduct(input); Assert.AreEqual(response.Success, true); Assert.AreEqual(EditManager.NewProduct.ProductType, "Wood"); Assert.AreEqual(EditManager.NewProduct.CostPerSquareFoot, 5.15M); Assert.AreEqual(EditManager.NewProduct.LaborCostPerSquareFoot, 4.75M); Assert.AreEqual(EditManager.NewProductType, "Wood"); }
public static void TaxAndTotalUpdatesCorrectly(string testState) { OrderRepository OrderRepo = new OrderRepository(); EditOrderManager EditManager = new EditOrderManager(OrderRepo); TaxRateRepository TaxRateRepo = new TaxRateRepository(); EditManager.OrderToEdit.Product = new Product(); EditManager.OrderToEdit.Product.ProductType = "Carpet"; EditManager.OrderToEdit.Product.CostPerSquareFoot = 2.25M; EditManager.OrderToEdit.Product.LaborCostPerSquareFoot = 2.10M; EditManager.OrderToEdit.Area = 200M; EditManager.OrderToEdit.ProductType = "Carpet"; EditManager.OrderToEdit.State = States.OH; EditManager.NewArea = 200M; //sets new state EditManager.ValidateState(testState); //sets Taxrate EditManager.CalculateNewTaxRate(); EditManager.ValidateProduct(""); EditManager.CalculateNewLaborCost(); EditManager.CalculateNewMaterialCost(); EditManager.CalculateNewTax(); TaxRate testRate = TaxRateRepo.TaxRateList.Find(x => x.StateAbbreviation.Contains(testState)); decimal rate = testRate.Rate; decimal expectedTax = (EditManager.NewMaterialCost + EditManager.NewLaborCost) * (rate / 100); Assert.AreEqual(expectedTax, EditManager.NewTax); EditManager.CalculateNewTotal(); decimal expectedTotal = EditManager.NewMaterialCost + EditManager.NewLaborCost + expectedTax; Assert.AreEqual(expectedTotal, EditManager.NewTotal); //what was the old tax, what is the new Tax }