Beispiel #1
0
        public void Adjustment_RemoveItem_DeveGerarDomainExceptionAoFecharORegistroQueEstaFechado()
        {
            // Arange
            Adjustment adjustment = AdjustmentFaker.GenerateFaker().Generate();

            adjustment.Close();

            // Act
            Action act = () => adjustment.Close();

            // Assert
            act.Should().Throw <DomainException>();
        }
        public async Task CloseAsync(Adjustment adjustment)
        {
            adjustment.Close();

            _repository.Update(adjustment);

            adjustment.AddEvent(new AdjustmentClosedEvent(adjustment.Id));

            await _repository.UnitOfWork.CommitAsync();
        }
        public void AdjustmentService_Close_DeveGerarDomainExceptionQuandoQuandoEstiverFechadoETentarFecharNovamente()
        {
            // Arange
            Adjustment adjustment = AdjustmentFaker.GenerateFaker().Generate();

            adjustment.Close();

            ConfigureMock();

            FactoryService();

            // Act
            Action act = () => adjustment.Close();

            // Assert
            act.Should().Throw <DomainException>();
            _adjustmentRepositoryMock.Verify(x => x.Update(It.IsAny <Adjustment>()), Times.Never);
            _unitOfWork.Verify(x => x.CommitAsync(), Times.Never);
            _busHandlerMock.Verify(x => x.PublishDomainEvent(It.IsAny <AdjustmentClosedEvent>()), Times.Never);
        }
Beispiel #4
0
        public void Adjustment_AddItem_DeveSetarOStatusParaFechadoCorretamenteSeEstiverAberto()
        {
            // Arange
            Adjustment adjustment = AdjustmentFaker.GenerateFaker().Generate();

            // Act
            adjustment.Close();

            // Assert
            adjustment.State.Should().Be(AdjustmentState.Closed);
        }
Beispiel #5
0
        public void Adjustment_AddItem_DeveGerarDomainExceptionQuandoAdicionarUmItemEEstiverFechado()
        {
            // Arange
            Adjustment adjustment = AdjustmentFaker.GenerateFaker().Generate();

            adjustment.Close();

            AdjustmentItem item1 = AdjustmentItemFaker.GenerateFaker(adjustment).Generate();

            // Act
            Action act = () => adjustment.AddItem(item1);

            // Assert
            act.Should().Throw <DomainException>();
        }