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));
            }
        }
Esempio n. 2
0
        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>();
        }
Esempio n. 3
0
        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);
        }