public void PricingEngine_Add_Specific_PricingRules() { IPricingEngine pe = new PricingEngine(); pe.AddQuantityPricingRule(new QuantityPricingRule("A", 50)); pe.AddQuantityPricingRule(new QuantityPricingRule("A", 2, 80)); pe.AddQuantityDiscountPricingRule(new QuantityDiscountPricingRule("A", 3, 2)); decimal price = pe.GetItemTotalPrice("A", 3); decimal expectedPrice = 80; Assert.AreEqual(expectedPrice, price); }
public void If_QuantityDiscountPricingRule_A_3_2_And_Scan_3A_Then_Price_is_90() { IPricingEngine pe = new PricingEngine(); pe.AddQuantityDiscountPricingRule(new QuantityDiscountPricingRule("A", 3, 2)); pe.AddQuantityPricingRule(new QuantityPricingRule("A", 3, 130)); pe.AddQuantityPricingRule(new QuantityPricingRule("A", 2, 90)); pe.AddQuantityPricingRule(new QuantityPricingRule("A", 1, 50)); ICheckout co = new Checkout(pe); for (int i = 0; i < 3; i++) { co.Scan("A"); } decimal price = co.GetTotalPrice(); decimal expectedPrice = 90; Assert.AreEqual(expectedPrice, price); }