public void GiftVouchersCanOnlyBeRedeemedAgainstNonGiftVoucherProducts()
        {
            //Arrange
            var expectedTotal = 30.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.GiftVoucher));

            var giftVoucher1 = VoucherService.Get("XXX-XXX");
            var giftVoucher2 = VoucherService.Get("XXX-XXX");
            var giftVoucher3 = VoucherService.Get("XXX-XXX");
            var giftVoucher4 = VoucherService.Get("XXX-XXX");
            var giftVoucher5 = VoucherService.Get("XXX-XXX");
            var giftVoucher6 = VoucherService.Get("XXX-XXX");

            //Act
            basket.ApplyVoucher(giftVoucher1);
            basket.ApplyVoucher(giftVoucher2);
            basket.ApplyVoucher(giftVoucher3);
            basket.ApplyVoucher(giftVoucher4);
            basket.ApplyVoucher(giftVoucher5);
            basket.ApplyVoucher(giftVoucher6); //Edge case: sixth voucher should not be applied

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
        public void DiscountCannotBeNegative()
        {
            //Arrange
            var expectedTotal = 0.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.HeadLight));

            var offerVoucher1 = VoucherService.Get("XXX-XXX");

            //Act
            basket.ApplyVoucher(offerVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
Ejemplo n.º 3
0
        public void Basket1()
        {
            //Arrange
            var expectedTotal = 60.15m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat2));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper2));

            var giftVoucher1 = VoucherService.Get("XXX-XXX");

            //Act
            basket.ApplyVoucher(giftVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
        public void PurchaseOfGiftVouchersDoNotContributeToDiscountableBasketTotal()
        {
            //Arrange
            var expectedTotal = 55.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.GiftVoucher));

            var offerVoucher1 = VoucherService.Get("ZZZ-ZZZ");

            //Act
            basket.ApplyVoucher(offerVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
Ejemplo n.º 5
0
        public void Basket3()
        {
            //Arrange
            var expectedTotal = 51.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));
            basket.Add(ProductService.Get(ProductService.ProductCode.HeadLight));

            var offerVoucher1 = VoucherService.Get("YYY-YYY");

            //Act
            basket.ApplyVoucher(offerVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
        public void CannotApplyTheSameVoucherTwice()
        {
            //Arrange
            var expectedTotal = 46.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));

            var giftVoucher1 = VoucherService.Get("XXX-XXX");

            //Act
            basket.ApplyVoucher(giftVoucher1);
            basket.ApplyVoucher(giftVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
Ejemplo n.º 7
0
        public void Basket5()
        {
            //Arrange
            var expectedTotal = 55.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.GiftVoucher));

            var offerVoucher1  = VoucherService.Get("ZZZ-ZZZ");
            var expectedReason = new BasketTotalBelowThresholdReason(offerVoucher1, 25.00m);

            //Act
            basket.ApplyVoucher(offerVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
            Assert.Equal(expectedReason.Message, basket.VoucherResults.First().Message);
        }
Ejemplo n.º 8
0
        public void Basket4()
        {
            //Arrange
            var expectedTotal = 41.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));

            var giftVoucher1  = VoucherService.Get("XXX-XXX");
            var offerVoucher1 = VoucherService.Get("ZZZ-ZZZ");

            //Act
            basket.ApplyVoucher(giftVoucher1);
            basket.ApplyVoucher(offerVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
Ejemplo n.º 9
0
        public void Basket2()
        {
            //Arrange
            var expectedTotal = 51.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));

            var offerVoucher1  = VoucherService.Get("YYY-YYY");
            var expectedReason = new NoApplicableProductsReason(offerVoucher1);

            //Act
            basket.ApplyVoucher(offerVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
            Assert.Equal(expectedReason.Message, basket.VoucherResults.First().Message);
        }
Ejemplo n.º 10
0
        public void MultipleGiftVouchersCanBeAppliedToABasket()
        {
            //Arrange
            var expectedTotal = 41.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));

            var giftVoucher1 = VoucherService.Get("XXX-XXX");
            var giftVoucher2 = VoucherService.Get("XXX-XXX");

            //Act
            basket.ApplyVoucher(giftVoucher1);
            basket.ApplyVoucher(giftVoucher2);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
        public void OnlyASingleOfferVoucherCanBeAppliedToABasket()
        {
            //Arrange
            var expectedTotal = 46.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));

            var offerVoucher1 = VoucherService.Get("ZZZ-ZZZ");
            var offerVoucher2 = VoucherService.Get("ZZZ-ZZZ");

            //Act
            basket.ApplyVoucher(offerVoucher1);
            basket.ApplyVoucher(offerVoucher2);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
        public void RemovingAnItemFromTheBasketAmendsDiscountRetroactively()
        {
            //Arrange
            var expectedTotal = 51.00m;

            var headlight = ProductService.Get(ProductService.ProductCode.HeadLight);

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));
            basket.Add(headlight);

            var offerVoucher1 = VoucherService.Get("YYY-YYY");

            //Act
            basket.ApplyVoucher(offerVoucher1);
            basket.Remove(headlight);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
        public void ThresholdMustBeMatchedOrExceeded()
        {
            //Arrange
            var expectedTotal = 25.00m;

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));

            var offerVoucher1 = VoucherService.Get("ZZZ-ZZZ");

            //Act
            basket.ApplyVoucher(offerVoucher1);

            //Assert
            Assert.Equal(expectedTotal, basket.DiscountedTotal);

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            expectedTotal = 45.00m;

            Assert.Equal(expectedTotal, basket.DiscountedTotal);
        }
        public void InvalidatedVouchersDisplayCorrectMessage()
        {
            //Arrange
            var expectedTotal = 46.00m;

            var headlight = ProductService.Get(ProductService.ProductCode.HeadLight);

            var basket = new Basket();

            basket.Add(ProductService.Get(ProductService.ProductCode.Hat));
            basket.Add(ProductService.Get(ProductService.ProductCode.Jumper));
            basket.Add(headlight);

            var offerVoucher1  = VoucherService.Get("YYY-YYY");
            var expectedReason = new NoApplicableProductsReason(offerVoucher1 as OfferVoucher);

            //Act
            basket.ApplyVoucher(offerVoucher1);
            Assert.DoesNotContain(basket.VoucherResults, r => r is NoApplicableProductsReason);
            basket.Remove(headlight);

            //Assert
            Assert.Equal(expectedReason.Message, basket.VoucherResults.First().Message);
        }