示例#1
0
        public void Scan7AItemsAnd2BItemAnd2DItemsAnd2cItemsShouldReturn425()
        {
            var chk = new Checkout();

            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("B");
            chk.Scan("B");
            chk.Scan("C");
            chk.Scan("C");
            chk.Scan("D");
            chk.Scan("D");
            Assert.AreEqual(425, chk.GetTotal());
        }
        public void can_apply_different_offers()
        {
            var checkout = new Checkout();

            var offers = new List <Offer>
            {
                new Offer("A", 2, 20),
                new Offer("J", 1, 10)
            };

            ScanItemMultipleTimes(checkout, _item1, 6); // total = 300, discount = 60
            ScanItemMultipleTimes(checkout, _item2, 4); // total = 120, discount = 0

            var expectedSubTotal = 420;
            var expectedDiscount = 60;
            var expectedTotal    = expectedSubTotal - expectedDiscount;

            Assert.Equal(expectedTotal, checkout.GetTotal(offers));
        }