public void UpdateBasketWithInvalidQuantity() { // arrange var sut = new BasketItem(1, 3); // act var ex = Assert.Throws <ArgumentException>(() => sut.UpdateQuantity(0)); // assert Assert.That(ex.Message, Is.EqualTo("newQuantity")); }
public void UpdateBasket() { // arrange var sut = new BasketItem(1, 3); // act sut.UpdateQuantity(6); // assert Assert.That(sut.ProductId, Is.EqualTo(1)); Assert.That(sut.Quantity, Is.EqualTo(6)); }
public async Task HandleAsync(UpdateBasket command, ICorrelationContext context) { CustomerBasket basket = await _basketRepo.GetAsync(command.BasketId); if (basket is null) { throw new MedParkException("basket_does_not_exist", $"The basket {command.BasketId} does not exist."); } command.Items.ToList().ForEach(async(item) => { BasketItem bItem = await _basketItemRepo.GetAsync(x => x.BasketId == basket.Id && x.ProductId == item.ProductId); bItem.UpdateQuantity(item.Quantity); bItem.UpdatedModifiedDate(); await _basketItemRepo.UpdateAsync(bItem); }); }