Пример #1
0
        public async Task Then_the_account_changes_are_persisted_to_the_domain_repository()
        {
            //Arrange
            var command          = _fixture.Create <RemoveLegalEntityCommand>();
            var legalEntityModel = _fixture.Create <LegalEntityModel>();

            legalEntityModel.Id = command.AccountId;
            legalEntityModel.AccountLegalEntityId = command.AccountLegalEntityId;

            _accountDomainRepository
            .Setup(m => m.Find(command.AccountId))
            .ReturnsAsync(Account.Create(
                              new AccountModel
            {
                Id = command.AccountId,
                LegalEntityModels = new Collection <LegalEntityModel>()
                {
                    _fixture.Create <LegalEntityModel>(),
                    legalEntityModel,
                    _fixture.Create <LegalEntityModel>(),
                }
            }));

            //Act
            await _sut.Handle(command);

            //Assert
            _accountDomainRepository.Verify(m => m.Save(It.Is <Account>(i => i.Id == command.AccountId && i.LegalEntities.Count == 2)), Times.Once);
        }
Пример #2
0
        public async Task Then_the_account_changes_are_not_persisted_to_the_domain_repository_if_the_account_exists_but_the_legalEntity_does_not_exist()
        {
            //Arrange
            var command = _fixture.Create <RemoveLegalEntityCommand>();

            _accountDomainRepository
            .Setup(m => m.Find(command.AccountId))
            .ReturnsAsync(Account.Create(new AccountModel {
                Id = 1, LegalEntityModels = new Collection <LegalEntityModel>()
                {
                    _fixture.Create <LegalEntityModel>()
                }
            }));

            //Act
            await _sut.Handle(command);

            //Assert
            _accountDomainRepository.Verify(m => m.Save(It.Is <Account>(i => i.Id == command.AccountId)), Times.Never);
        }