public void AddItemToBasket(int customerId, [FromBody] ShoppingBasketItemInsertVM newItem)
        {
            var item = new ShoppingBasketItem(newItem);

            _shoppingBasketService.AddItemToBasket(customerId, item);
        }
示例#2
0
        public void AddItemToBasket_WhenAddingAnItemToABasket_AndBasketExists_AndTheItemDoesNotExists_ThenTheItemIsAddedToTheBasket()
        {
            var basketItemsCount = _shoppingBasketService.GetBasketForCustomer(1).OrderItems.Count();

            var item = new ShoppingBasketItem
            {
                ProductId   = 677,
                Price       = 15,
                ProductName = "The Art of Unit Test Book",
                Quantity    = 1
            };

            _shoppingBasketService.AddItemToBasket(1, item);

            var basket = _shoppingBasketService.GetBasketForCustomer(1);

            Assert.AreEqual(basketItemsCount + 1, basket.OrderItems.Count());
            Assert.IsTrue(basket.OrderItems.Exists(i => i.ProductId == 677));
        }