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_MultiPriceRule_B_2_45_And_MultiPriceRule_A_3_130_And_Scan_AAABBD_Then_Price_is_190()
        {
            IPricingEngine pe = new PricingEngine();
            pe.AddQuantityPricingRule(new QuantityPricingRule("A", 50));
            pe.AddQuantityPricingRule(new QuantityPricingRule("B", 30));
            pe.AddQuantityPricingRule(new QuantityPricingRule("D", 15));
            pe.AddQuantityPricingRule(new QuantityPricingRule("A", 3, 130));
            pe.AddQuantityPricingRule(new QuantityPricingRule("B", 2, 45));

            ICheckout co = new Checkout(pe);

            co.Scan("A");
            co.Scan("A");
            co.Scan("A");
            co.Scan("B");
            co.Scan("B");
            co.Scan("D");

            decimal price = co.GetTotalPrice();
            decimal expectedPrice = 190;

            Assert.AreEqual(expectedPrice, price);
        }
        public void If_QuantityPricingRule_A_50_And_Scan_AA_Then_Price_is_100()
        {
            IPricingEngine pe = new PricingEngine();
            pe.AddQuantityPricingRule(new QuantityPricingRule("A", 50));
            pe.AddQuantityPricingRule(new QuantityPricingRule("B", 30));

            ICheckout co = new Checkout(pe);

            co.Scan("A");
            co.Scan("A");

            decimal price = co.GetTotalPrice();
            decimal expectedPrice = 100;

            Assert.AreEqual(expectedPrice, price);
        }
        public void If_Scan_CDBA_Then_Price_is_115()
        {
            IPricingEngine pe = new PricingEngine();
            pe.AddQuantityPricingRule(new QuantityPricingRule("A", 50));
            pe.AddQuantityPricingRule(new QuantityPricingRule("B", 30));
            pe.AddQuantityPricingRule(new QuantityPricingRule("C", 20));
            pe.AddQuantityPricingRule(new QuantityPricingRule("D", 15));

            ICheckout co = new Checkout(pe);
            co.Scan("C");
            co.Scan("D");
            co.Scan("B");
            co.Scan("A");
            decimal price = co.GetTotalPrice();
            decimal expectedPrice = 115;

            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);
        }