public void Scenario_Two_Success() { // Arrange var listOfProducts = new List <IProduct> { new ImportedProduct("box of chocolates", 10.00m, 1, ProductType.Food), new ImportedProduct("bottle of perfume", 47.50m, 1, ProductType.Perfume) }; var chargeRate = new ChargeRate(10, 5); // Act listOfProducts = TaxCalculationLogic.CalculateTax(listOfProducts, chargeRate).ToList(); // Assert Assert.AreEqual(10.50m, listOfProducts[0].TotalPriceIncTax); Assert.AreEqual(54.63m, listOfProducts[1].TotalPriceIncTax); Assert.AreEqual(7.63m, listOfProducts.Sum(product => product.ProductTax)); Assert.AreEqual(65.13m, listOfProducts.Sum(product => product.TotalPriceIncTax)); }
public void Receipt_GetSubtotalIncTax_Success() { // Arrange var listOfProduct = new List <IProduct> { new Product("vitamin C 30 Tablets", 13.82m, 1, ProductType.MedicalProduct), new Product("D&G Blue", 42.99m, 1, ProductType.Perfume), new ImportedProduct("Box of apples", 3.56m, 3, ProductType.Food), new ImportedProduct("3D Puzzle", 10m, 2, ProductType.None) }; var chargeRate = new ChargeRate(10m, 5m); // Act listOfProduct = TaxCalculationLogic.CalculateTax(listOfProduct, chargeRate).ToList(); var receipt = new Receipt(listOfProduct); var subtotalIncTax = receipt.SubtotalIncTax; // Assert Assert.AreEqual(95.33m, subtotalIncTax); }
public void Scenario_One_Success() { // Arrange var listOfProducts = new List <IProduct> { new Product("book", 12.49m, 1, ProductType.Book), new Product("music CD", 14.99m, 1, ProductType.None), new Product("chocolate bar", 0.85m, 1, ProductType.Food) }; var chargeRate = new ChargeRate(10, 5); // Act listOfProducts = TaxCalculationLogic.CalculateTax(listOfProducts, chargeRate).ToList(); // Assert Assert.AreEqual(12.49m, listOfProducts[0].TotalPriceIncTax); Assert.AreEqual(16.49m, listOfProducts[1].TotalPriceIncTax); Assert.AreEqual(0.85m, listOfProducts[2].TotalPriceIncTax); Assert.AreEqual(1.50m, listOfProducts.Sum(product => product.ProductTax)); Assert.AreEqual(29.83m, listOfProducts.Sum(product => product.TotalPriceIncTax)); }
public void Scenario_Three_Success() { // Arrange var listOfProducts = new List <IProduct> { new ImportedProduct("bottle of perfume", 27.99m, 1, ProductType.Perfume), new Product("bottle of perfume", 18.99m, 1, ProductType.Perfume), new Product("packet of headache pills", 9.75m, 1, ProductType.MedicalProduct), new ImportedProduct("box of chocolates", 11.25m, 1, ProductType.Food) }; var chargeRate = new ChargeRate(10, 5); // Act TaxCalculationLogic.CalculateTax(listOfProducts, chargeRate); // Assert Assert.AreEqual(32.19m, listOfProducts[0].TotalPriceIncTax); Assert.AreEqual(20.89m, listOfProducts[1].TotalPriceIncTax); Assert.AreEqual(9.75m, listOfProducts[2].TotalPriceIncTax); Assert.AreEqual(11.81m, listOfProducts[3].TotalPriceIncTax); Assert.AreEqual(6.66m, listOfProducts.Sum(product => product.ProductTax)); Assert.AreEqual(74.64m, listOfProducts.Sum(product => product.TotalPriceIncTax)); }
public void TaxCalculation_RecalculateForAllProduct_Realculated() { // Arrange var listOfProduct = new List <IProduct> { new Product("vitamin C 30 Tablets", 13.82m, 1, ProductType.MedicalProduct), new Product("D&G Blue", 42.99m, 1, ProductType.Perfume), new ImportedProduct("Box of apples", 3.56m, 3, ProductType.Food), new ImportedProduct("3D Puzzle", 10m, 2, ProductType.None) }; var chargeRate = new ChargeRate(12.06m, 5.2m); // Act listOfProduct[1].ProductTax = 3.5m; listOfProduct[2].ProductTax = 5.5m; var listOfProductWithTax = TaxCalculationLogic.CalculateTax(listOfProduct, chargeRate, recalculateAll: true); // Assert Assert.AreEqual(4, listOfProductWithTax.Count); Assert.AreEqual(0, listOfProductWithTax[0].ProductTax); Assert.AreEqual(5.18m, listOfProductWithTax[1].ProductTax); Assert.AreEqual(0.19m, listOfProductWithTax[2].ProductTax); Assert.AreEqual(1.73m, listOfProductWithTax[3].ProductTax); }
public void TaxCalculation_SingleProduct_ChargeRateParameterNull_Fail() { TaxCalculationLogic.CalculateTax(new Product(), null); }
public void TaxCalculation_ListOfProucts_ChargeRateParameterNull_Fail() { TaxCalculationLogic.CalculateTax(new List <IProduct> { new Product(), new Product() }, null); }
public void TaxCalculation_ListOfProductParameterNull_Fail() { TaxCalculationLogic.CalculateTax(new List <IProduct> { new Product(), null }, new ChargeRate(10m, 5m)); }
public void TaxCalculation_ProductParameterNull_Fail() { TaxCalculationLogic.CalculateTax(null, new ChargeRate(10m, 5m)); }