public async Task UpdateItemAsync(Adjustment adjustment, AdjustmentItem item) { adjustment.UpdateItem(item); _repository.Update(adjustment); if (await _repository.UnitOfWork.CommitAsync()) { await _bus.PublishDomainEvent(new AdjustmentItemUpdated(item.Id)); } }
public void Adjustment_UpdateItem_DeveGerarDomainExceptionQuandoTentarAtualizarUmItemInexistente() { // Arange Adjustment adjustment = AdjustmentFaker.GenerateFaker().Generate(); AdjustmentItem adjustmentItem = AdjustmentItemFaker.GenerateFaker(adjustment).Generate(); // Act Action act = () => adjustment.UpdateItem(adjustmentItem); // Assert act.Should().Throw <DomainException>(); }
public void Adjustment_UpdateItem_DeveAtualizarCorretamenteUmItemQuandoOMesmoExistir() { // Arange Adjustment adjustment = AdjustmentFaker.GenerateFaker().Generate(); AdjustmentItem adjustmentItem = AdjustmentItemFaker.GenerateFaker(adjustment).Generate(); adjustment.AddItem(adjustmentItem); // Act adjustment.UpdateItem(adjustmentItem); // Assert adjustment.Items.Should().HaveCount(1); }