public void TestSpecialOffersCanBeAdded_Null()
        {
            // Arrange
            ICheckout checkout = new Checkout();

            // Act
            checkout.AddSpecialOffer(null);

            // Assert
            Assert.Fail("ArgumentNullException was not thrown.");
        }
        public void CanApplySpecialOffer()
        {
            var item1 = new ItemBuilder().WithSku("A99").WithPrice(0.50m).Build();
            var item2 = new ItemBuilder().WithSku("B15").WithPrice(0.30m).Build();
            var item3 = new ItemBuilder().WithSku("B15").WithPrice(0.30m).Build();

            var offer = new SpecialOffer {
                Sku = "B15", Price = 0.45m, Quantity = 2
            };

            // this does require the offer to be added before scanning.
            // However gives flexibility that you can add offers rather than them being set in the Checkout itself.
            _itemUnderTest.AddSpecialOffer(offer);

            _itemUnderTest.Scan(item1);
            _itemUnderTest.Scan(item2);
            _itemUnderTest.Scan(item3);

            _itemUnderTest.Total().ShouldEqual(0.95m);
        }
        public void TestSpecialOffersAreApplied()
        {
            // Arrange
            ICheckout checkout = new Checkout();

            checkout.AddItem(new CheckoutItem("B", 30));
            checkout.AddItem(new CheckoutItem("A", 50));
            checkout.AddItem(new CheckoutItem("B", 30));

            // Act
            checkout.AddSpecialOffer(new MultiBuySpecialOffer(2, "B", 45));

            // Assert
            Assert.AreEqual(95, checkout.CalculateTotal());
        }
        public void TestSpecialOffersCanBeAdded()
        {
            // Arrange
            ICheckout checkout = new Checkout();

            checkout.AddItem(new CheckoutItem("B", 30));
            checkout.AddItem(new CheckoutItem("A", 50));
            checkout.AddItem(new CheckoutItem("B", 30));

            // Act
            checkout.AddSpecialOffer(new MultiBuySpecialOffer(2, "B", 45));

            // Assert
            Assert.AreEqual(1, checkout.SpecialOffers.Count);
        }
        public void TestSpecialOffersAreApplied_WithAdditionalItemsNotCoveredByOffer()
        {
            // Arrange
            ICheckout checkout = new Checkout();

            checkout.AddItem(new CheckoutItem("B", 30));
            checkout.AddItem(new CheckoutItem("A", 50));
            checkout.AddItem(new CheckoutItem("B", 30));
            checkout.AddItem(new CheckoutItem("B", 30));

            // Act
            checkout.AddSpecialOffer(new MultiBuySpecialOffer(2, "B", 45));

            // Assert
            Assert.AreEqual(125, checkout.CalculateTotal());
        }