public void Multiple_Gift_vouchers_can_be_redeemed()
        {
            var product1 = new Product {
                Id = 1, Name = "Jumper", Price = 30M, Category = ProductCategory.Clothing
            };
            var product2 = new Product {
                Id = 2, Name = "Suit", Price = 250M, Category = ProductCategory.Clothing
            };
            var voucher1 = new GiftVoucher {
                Name = "XXX-XXX", Value = 50M
            };
            var voucher2 = new GiftVoucher {
                Name = "ggg-ggg", Value = 25M
            };

            var mock = new Mock <IProductService>();

            mock.Setup(s => s.Get(1)).Returns(product1);
            mock.Setup(s => s.Get(2)).Returns(product2);

            var basket = new Basket(new GiftVoucherService(), mock.Object);

            basket.AddProduct(1);
            basket.AddProduct(2);
            basket.AddGiftVoucher(voucher1);
            basket.AddGiftVoucher(voucher2);

            Assert.AreEqual(205M, basket.Total);
            Assert.IsNull(basket.Message);
        }
        public void Multiple_voucher_total_value_is_greater_than_basket_total()
        {
            var product1 = new Product {
                Id = 1, Name = "Jumper", Price = 30M, Category = ProductCategory.Clothing
            };
            var voucher1 = new GiftVoucher {
                Name = "XXX-XXX", Value = 50M
            };
            var voucher2 = new GiftVoucher {
                Name = "XXX-XXX", Value = 50M
            };

            var mock = new Mock <IProductService>();

            mock.Setup(s => s.Get(1)).Returns(product1);

            var basket = new Basket(new GiftVoucherService(), mock.Object);

            basket.AddProduct(1);
            basket.AddGiftVoucher(voucher1);
            basket.AddGiftVoucher(voucher2);

            Assert.AreEqual(0M, basket.Total);
            Assert.AreEqual("You still have £70.00 left on the gift voucher", basket.Message);
        }
        public void Basket4()
        {
            var product1 = new Product {
                Name = "Hat", Price = 25.00M, Category = ProductCategory.Clothing
            };
            var product2 = new Product {
                Name = "Jumper", Price = 26M, Category = ProductCategory.Clothing
            };
            var offerVoucher = new OfferVoucher {
                Name = "YYY-YYY", Discount = 5M, Threshold = 50
            };
            var giftVoucher = new GiftVoucher {
                Name = "XXX-XXX", Value = 5M
            };

            var basket = new Basket(new GiftVoucherService(), new ProductService(new Data.ProductRepository()));

            basket.AddProduct(1);
            basket.AddProduct(4);
            basket.Voucher = offerVoucher;
            basket.AddGiftVoucher(giftVoucher);

            Assert.AreEqual(41M, basket.Total);
            Assert.IsNull(basket.Message);
        }
        public void Gift_vouchers_can_only_be_redeemed_against_non_gift_voucher_products()
        {
            var product1 = new Product {
                Id = 1, Name = "Jumper", Price = 30M, Category = ProductCategory.Clothing
            };
            var product2 = new Product {
                Id = 2, Name = "ggg-ggg", Price = 20M, Category = ProductCategory.GiftVoucher
            };
            var voucher = new GiftVoucher {
                Name = "XXX-XXX", Value = 50M
            };

            var mock = new Mock <IProductService>();

            mock.Setup(s => s.Get(1)).Returns(product1);
            mock.Setup(s => s.Get(2)).Returns(product2);

            var basket = new Basket(new GiftVoucherService(), mock.Object);

            basket.AddProduct(1);
            basket.AddProduct(2);
            basket.AddGiftVoucher(voucher);

            Assert.AreEqual(50.00M, basket.Total);
            Assert.AreEqual("Gift vouchers can only be redeemed against non gift voucher products.", basket.Message);
        }
Beispiel #5
0
        public void WhenMultipleGiftVoucherAddedBasketTotalPriceIsReduced()
        {
            var basket = new Basket();

            basket.AddProduct("hat1050", 1);
            basket.AddGiftVoucher("XXX-XXX", 2);

            Assert.Equal(0.5m, basket.TotalPrice);
        }
        public void Basket1()
        {
            var basket = new Basket();

            basket.AddProduct("hat1050", 1);
            basket.AddProduct("jumper5465", 1);
            basket.AddGiftVoucher("XXX-XXX", 1);

            Assert.Equal(60.15m, basket.TotalPrice);
        }
        public void Basket4()
        {
            var basket = new Basket();

            basket.AddProduct("hat2500", 1);
            basket.AddProduct("jumper2600", 1);
            basket.AddGiftVoucher("XXX-XXX", 1);
            basket.AddOfferVoucher("YYY-YYY");

            Assert.Equal(41m, basket.TotalPrice);
        }
        public void Basket3()
        {
            var basket = new Basket();

            basket.AddProduct("hat2500", 1);
            basket.AddProduct("jumper2600", 1);
            basket.AddProduct("headlight350", 1);
            basket.AddGiftVoucher("YYY-YYY", 1);

            Assert.Equal(51.00m, basket.TotalPrice);
        }
        public void Basket2()
        {
            var basket = new Basket();

            basket.AddProduct("hat2500", 1);
            basket.AddProduct("jumper2600", 1);
            basket.AddGiftVoucher("YYY-YYY", 1);

            Assert.Equal(51.00m, basket.TotalPrice);
            Assert.Equal("There are no products in your basket applicable to voucher Voucher YYY-YYY .", basket.Message);
        }
        public void Basket1()
        {
            var product1 = new Product {
                Name = "Hat", Price = 10.50M, Category = ProductCategory.Clothing
            };
            var product2 = new Product {
                Name = "Jumper", Price = 54.65M, Category = ProductCategory.Clothing
            };
            var voucher = new GiftVoucher {
                Name = "XXX-XXX", Value = 5M
            };

            var basket = new Basket(new GiftVoucherService(), new ProductService(new Data.ProductRepository()));

            basket.AddProduct(2);
            basket.AddProduct(5);
            basket.AddGiftVoucher(voucher);

            Assert.AreEqual(60.15M, basket.Total);
        }
        public void Single_Gift_vouchers_redeemed()
        {
            var product1 = new Product {
                Id = 1, Name = "Jumper", Price = 30M, Category = ProductCategory.Clothing
            };
            var voucher = new GiftVoucher {
                Name = "XXX-XXX", Value = 10M
            };

            var mock = new Mock <IProductService>();

            mock.Setup(s => s.Get(1)).Returns(product1);

            var basket = new Basket(new GiftVoucherService(), mock.Object);

            basket.AddProduct(1);
            basket.AddGiftVoucher(voucher);

            Assert.AreEqual(20.00M, basket.Total);
            Assert.IsNull(basket.Message);
        }