コード例 #1
0
        public void CalculateBasketPrice_BasketIsEmpty_ReturnsZero()
        {
            IBasket basket = new Basket();

            IBasketCalculatorService calculator = new BasketCalculatorService(fakeProductService);

            Assert.Equal(0m, calculator.CalculateBasketPrice(basket));
        }
コード例 #2
0
        public void CalculateBasketPrice_BasketHasOneOfEachProduct_ReturnsCorrectTotal()
        {
            IBasket basket = new Basket();

            basket.Items.Add(fakeButter);
            basket.Items.Add(fakeMilk);
            basket.Items.Add(fakeBread);

            IBasketCalculatorService calculator = new BasketCalculatorService(fakeProductService);

            Assert.Equal(2.95m, calculator.CalculateBasketPrice(basket));
        }
コード例 #3
0
        public void CalculateBasketPrice_BasketHasTwoButterAndTwoBread_ReturnsCorrectTotalAfterOffer()
        {
            IBasket basket = new Basket();

            basket.Items.Add(fakeButter);
            basket.Items.Add(fakeButter);
            basket.Items.Add(fakeBread);
            basket.Items.Add(fakeBread);

            IBasketCalculatorService calculator = new BasketCalculatorService(fakeProductService);

            Assert.Equal(3.1m, calculator.CalculateBasketPrice(basket));
        }
コード例 #4
0
        public void CalculateBasketPrice_BasketHasFourMilk_ReturnsCorrectTotalAfterOffer()
        {
            IBasket basket = new Basket();

            basket.Items.Add(fakeMilk);
            basket.Items.Add(fakeMilk);
            basket.Items.Add(fakeMilk);
            basket.Items.Add(fakeMilk);

            IBasketCalculatorService calculator = new BasketCalculatorService(fakeProductService);

            Assert.Equal(3.45m, calculator.CalculateBasketPrice(basket));
        }
コード例 #5
0
        public void CalculateBasketPrice_ItemPriceHasBeenTamperedWith_BasketIsRecertifiedAndPriceCorrected()
        {
            IBasket basket = new Basket();

            Product forgedButter = new Product
            {
                Id    = 1,
                Name  = "Butter",
                Price = 0.8m
            };

            basket.Items.Add(forgedButter);

            fakeProductService.GetProducts().ReturnsForAnyArgs(new List <Product> {
                fakeButter
            });

            IBasketCalculatorService calculator = new BasketCalculatorService(fakeProductService);

            Assert.Equal(0.8m, calculator.CalculateBasketPrice(basket));
        }