Exemplo n.º 1
0
        private void AddProductToBasket(Guid basketId, ProductData product)
        {
            var basket = _basketRepository.GetFirstOrDefault(z => z.Id == basketId);

            if (basket == null)
            {
                return;
            }
            basket.Total = basket.Total + product.Count * product.Price;
            _basketRepository.UpdateBasket(basket);
        }
Exemplo n.º 2
0
        public async Task UpdateBasket()
        {
            // arrange
            var basket = new BasketOfItems(1);
            await _sut.CreateBasketAsync(basket);

            basket.AddUpdateOrRemoveItem(1, 4);

            // act
            await _sut.UpdateBasket(basket);

            // assert
            var dbBasket = await _context.Baskets.FirstOrDefaultAsync(x => x.Id.Equals(basket.Id));

            Assert.That(dbBasket, Is.Not.Null);
            Assert.That(dbBasket.BasketItems, Has.Count.EqualTo(1));
            Assert.That(dbBasket.BasketItems.All(x => x.Quantity.Equals(4)));
        }