Ejemplo n.º 1
0
 public void GivenForEveryApplesThereIsADiscountOf(int multiple, decimal discount)
 {
     testBasket.AddDiscount(
         basket => basket.Items
         .Where(item => item.ItemName == "Apple")
         .Where((_, index) => (index + 1) % multiple == 0)
         , item => item.Price - discount);
 }
        public void Basket4()
        {
            IProduct hat    = new Product("hat", new decimal(25.00));
            IProduct jumper = new Product("jumper", new decimal(26.00));

            IDiscount giftCard     = new GiftVoucher("XXX-XXX", new decimal(5.00));
            IDiscount offerVoucher = new OfferVoucher("YYY-YYY", new decimal(5.00), new decimal(50.00));

            IBasket basket = new Basket();

            basket.AddProduct(hat, 1);
            basket.AddProduct(jumper, 1);

            basket.AddDiscount(giftCard);
            basket.AddDiscount(offerVoucher);

            Assert.AreEqual(41.00, basket.Total);
        }
        public void Basket1()
        {
            IProduct hat    = new Product("hat", new decimal(10.50));
            IProduct jumper = new Product("jumper", new decimal(54.65));

            IDiscount giftCard = new GiftVoucher("XXX-XXX", new decimal(5.00));

            IBasket basket = new Basket();

            basket.AddProduct(hat, 1);
            basket.AddProduct(jumper, 1);
            basket.AddDiscount(giftCard);

            Assert.AreEqual(60.15, basket.Total);
        }
        public void Basket5()
        {
            IProduct hat      = new Product("hat", new decimal(25.00));
            IProduct giftCard = new GiftCard("£30 Gift Voucher", new decimal(30.00));

            IDiscount offerVoucher = new OfferVoucher("YYY-YYY", new decimal(5.00), new decimal(50.00));

            IBasket basket = new Basket();

            basket.AddProduct(hat, 1);
            basket.AddProduct(giftCard, 1);

            basket.AddDiscount(offerVoucher);

            Assert.AreEqual(true, basket.ErrorInBasket);
            Assert.IsNotEmpty(basket.ErrorMessage);
        }
        public void Basket2()
        {
            IProduct hat    = new Product("hat", new decimal(25.00));
            IProduct jumper = new Product("jumper", new decimal(26.00));

            ICategory headGearCategory = new Category("headgear");

            IDiscount headgearOffer = new OfferVoucher("YYY-YYY", new decimal(5.00), new decimal(50.00), headGearCategory);

            IBasket basket = new Basket();

            basket.AddProduct(hat, 1);
            basket.AddProduct(jumper, 1);

            basket.AddDiscount(headgearOffer);

            Assert.AreEqual(true, basket.ErrorInBasket);
            Assert.IsNotEmpty(basket.ErrorMessage);
        }
        public void Basket3()
        {
            ICategory headGearCategory = new Category("headgear");

            IProduct hat       = new Product("hat", new decimal(25.00));
            IProduct jumper    = new Product("jumper", new decimal(26.00));
            IProduct headLight = new Product(headGearCategory, "head light", new decimal(3.50));

            IDiscount headgearOffer = new OfferVoucher("YYY-YYY", new decimal(5.00), new decimal(50.00), headGearCategory);

            IBasket basket = new Basket();

            basket.AddProduct(hat, 1);
            basket.AddProduct(jumper, 1);
            basket.AddProduct(headLight, 1);

            basket.AddDiscount(headgearOffer);

            Assert.AreEqual(51.00, basket.Total);
        }