Example #1
0
        public void GetBasket_1_bread_1_butter_1_milk()
        {
            userBasketRepo.Setup(b => b.Get(It.IsAny <Func <IUserBasketItem, bool> >()))
            .Returns(() =>
            {
                return(new List <IBasketItem>
                {
                    new BasketItem()
                    {
                        Id = 1, Name = "Butter", Price = 0.8
                    },
                    new BasketItem()
                    {
                        Id = 2, Name = "Milk", Price = 1.15
                    },
                    new BasketItem()
                    {
                        Id = 3, Name = "Bread", Price = 1.0
                    },
                });
            });

            SetupDiscounts();

            var service = new ShoppingBasketService(userBasketRepo.Object, basketItemRepo.Object, discountRepo.Object);

            var basket = service.GetUserBasket(USER_ID);

            PrintBasketToConsole(basket);

            Assert.IsTrue(basket.DiscountPrice == 2.95);
            Assert.IsTrue(basket.TotalPrice == 2.95);
        }
Example #2
0
        public void GetBasket_NoItems()
        {
            userBasketRepo.Setup(b => b.Get(It.IsAny <Func <IUserBasketItem, bool> >()))
            .Returns(() => null);

            SetupDiscounts();

            var service = new ShoppingBasketService(userBasketRepo.Object, basketItemRepo.Object, discountRepo.Object);

            var basket = service.GetUserBasket(USER_ID);

            PrintBasketToConsole(basket);

            Assert.IsTrue(basket.TotalPrice == 0);
            Assert.IsTrue(basket.DiscountPrice == 0);
        }