public void CalculateForDiscount_Should_Return_Correct_Sum(string productCodes, double totalPrice) { // arrange IPointOfSaleTerminal terminal = new PointOfSaleTerminal(); IReadOnlyDictionary <string, ProductPricingSettings> settings = new Dictionary <string, ProductPricingSettings> { { "A", new ProductPricingSettings(1.25, 3, 3) }, { "B", new ProductPricingSettings(4.25) }, { "C", new ProductPricingSettings(1, 5, 6) }, { "D", new ProductPricingSettings(0.75) }, { "E", new ProductPricingSettings(1, 0.75, 1) } }; terminal.SetPricing(settings); foreach (char productCode in productCodes) { terminal.Scan(productCode.ToString()); } // act double result = terminal.CalculateForDiscount(); // assert Assert.Equal(totalPrice, result); }
public void CalculateForDiscount_Should_Return_0_If_ProductPricingSettings_Is_Null_or_Empty() { // arrange IPointOfSaleTerminal terminal = new PointOfSaleTerminal(); // act double result = terminal.CalculateForDiscount(); // assert Assert.Equal(0, result); }
public void CalculateForDiscount_Should_Return_0_If_No_Scan() { // arrange IPointOfSaleTerminal terminal = new PointOfSaleTerminal(); IReadOnlyDictionary <string, ProductPricingSettings> settings = new Dictionary <string, ProductPricingSettings> { { "A", new ProductPricingSettings(1.25, 3, 3) }, { "B", new ProductPricingSettings(4.25) }, { "C", new ProductPricingSettings(1, 5, 6) }, { "D", new ProductPricingSettings(0.75) } }; terminal.SetPricing(settings); // act double result = terminal.CalculateForDiscount(); // assert Assert.Equal(0, result); }