Beispiel #1
0
        public void PriceCalculationLogic_MultipleQuantity_NoOffers()
        {
            //Arrange
            ISpecialOfferRepository specialOfferRepository = Substitute.For <ISpecialOfferRepository>();

            CheckoutItem checkoutItem = new CheckoutItem {
                Price = 0.5M, Quantity = 4
            };

            PriceCalculationLogic priceCalculationLogic = new PriceCalculationLogic(specialOfferRepository);

            //Act
            var price = priceCalculationLogic.GetPrice(checkoutItem);

            //Assert
            Assert.AreEqual(2m, price);
        }
Beispiel #2
0
        public void PriceCalculationLogic_MultipleQuantity_WithOffer_MultiQualifying()
        {
            //Arrange
            ISpecialOfferRepository specialOfferRepository = Substitute.For <ISpecialOfferRepository>();

            specialOfferRepository.GetBySku("A99").Returns(new SpecialOffer {
                Quantity = 3, OfferPrice = 1.3M
            });

            CheckoutItem checkoutItem = new CheckoutItem {
                Sku = "A99", Price = 0.5M, Quantity = 6
            };

            PriceCalculationLogic priceCalculationLogic = new PriceCalculationLogic(specialOfferRepository);

            //Act
            var price = priceCalculationLogic.GetPrice(checkoutItem);

            //Assert
            Assert.AreEqual(2.6m, price);
            specialOfferRepository.Received(1).GetBySku("A99");
        }