static void Main() { var terminal = new PointOfSaleTerminal(); terminal.SetPricing("A", 1.25m, 3, 3.00m); terminal.SetPricing("B", 4.25m, null, null); terminal.SetPricing("C", 1, 6, 5.00m); terminal.SetPricing("D", 0.75m, null, null); terminal.ScanProduct("A"); terminal.ScanProduct("B"); terminal.ScanProduct("C"); terminal.ScanProduct("D"); terminal.ScanProduct("A"); terminal.ScanProduct("B"); terminal.ScanProduct("A"); var totalSum = terminal.CalculateTotal(); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); terminal.ScanProduct("C"); totalSum = terminal.CalculateTotal(); terminal.ScanProduct("A"); terminal.ScanProduct("B"); terminal.ScanProduct("C"); terminal.ScanProduct("D"); totalSum = terminal.CalculateTotal(); }
public void SetPricing_ScanSingleUnitOfItem_CheckCalculatedPriceIsUnitPrice(string productName, decimal unitPrice, int bulkQuantity, decimal bulkPrice) { var terminal = new PointOfSaleTerminal(); terminal.SetPricing(productName, unitPrice, bulkQuantity, bulkPrice); terminal.ScanProduct(productName); Assert.AreEqual(unitPrice, terminal.CalculateTotal(), "Total Price for the scanned item should be equal to its unit price"); }
public void DoNotSetBulkPricing_Scan10Items_CheckCalculatedPriceIsbasedOnUnitPrice(string productName, decimal unitPrice, int bulkQuantity, decimal bulkPrice) { var terminal = new PointOfSaleTerminal(); terminal.SetPricing(productName, unitPrice, bulkQuantity, bulkPrice); for (var itemCount = 0; itemCount < 10; itemCount++) { terminal.ScanProduct(productName); } Assert.AreEqual(unitPrice * 10, terminal.CalculateTotal(), "Total Price for the scanned item should be equal to its ten times of its 10 times of unit price"); }
public void SetPricing_ScanBulkQuantityOfItem_CheckCalculatedPriceIsBulkPrice(string productName, decimal unitPrice, int bulkQuantity, decimal bulkPrice) { var terminal = new PointOfSaleTerminal(); terminal.SetPricing(productName, unitPrice, bulkQuantity, bulkPrice); for (var itemCount = 0; itemCount < bulkQuantity; itemCount++) { terminal.ScanProduct(productName); } Assert.AreEqual(bulkPrice, terminal.CalculateTotal(), "Total Price for the scanned item should be equal to its bulk price"); }
public void ScanSomeProducts_CalculatePrice_VerifyUnitPriceAndBulkPriceAppliedAccordingly(string[] listOfItemsToBeScanned, decimal expectedTotalSum) { var terminal = new PointOfSaleTerminal(); terminal.SetPricing("A", 1.25m, 3, 3.00m); terminal.SetPricing("B", 4.25m, null, null); terminal.SetPricing("C", 1, 6, 5.00m); terminal.SetPricing("D", 0.75m, null, null); foreach (var item in listOfItemsToBeScanned) { terminal.ScanProduct(item); } Assert.AreEqual(expectedTotalSum, terminal.CalculateTotal(), "Calculated price should be based on bulk price and unit price specified"); }