예제 #1
0
        public void Then_errors_if_the_model_id_is_not_set()
        {
            // Arrange

            // Act
            Action action = () => LegalEntity.Create(new LegalEntityModel());

            // Assert
            action.Should().Throw <ArgumentException>().Where(e => e.Message.StartsWith("Id is not set"));
        }
예제 #2
0
        public void Then_errors_if_the_model_is_null()
        {
            // Arrange

            // Act
            Action action = () => LegalEntity.Create(null);

            // Assert
            action.Should().Throw <ArgumentNullException>();
        }
        public void Then_the_accountLegalEntityId_is_set()
        {
            // Arrange
            var accountLegalEntityId = _fixture.Create <long>();

            // Act
            _sut.AddLegalEntity(accountLegalEntityId, LegalEntity.Create(_fixture.Create <LegalEntityModel>()));

            // Assert
            _sut.GetModel().LegalEntityModels.Single().AccountLegalEntityId.Should().Be(accountLegalEntityId);
        }
        public void Then_the_legalEntity_is_added()
        {
            // Arrange
            var legalEntity = LegalEntity.Create(_fixture.Create <LegalEntityModel>());

            // Act
            _sut.AddLegalEntity(_fixture.Create <long>(), legalEntity);

            // Assert
            _sut.LegalEntities.Single().Id.Should().Be(legalEntity.Id);
        }
        public void Then_has_signed_incentive_terms_is_not_changed_if_version_less_than_minimum_required(bool originalValue)
        {
            // Arrange
            var model       = _fixture.Build <LegalEntityModel>().With(x => x.HasSignedAgreementTerms, originalValue).Create();
            var legalEntity = LegalEntity.Create(model);

            // Act
            legalEntity.SignedAgreement(3, 4);

            // Assert
            legalEntity.HasSignedAgreementTerms.Should().Be(originalValue);
        }
        public void Then_has_signed_incentive_terms_is_true_if_version_equal_to_the_minimum_required()
        {
            // Arrange
            var model       = _fixture.Build <LegalEntityModel>().With(x => x.HasSignedAgreementTerms, false).Create();
            var legalEntity = LegalEntity.Create(model);

            // Act
            legalEntity.SignedAgreement(4, 4);

            // Assert
            legalEntity.HasSignedAgreementTerms.Should().BeTrue();
        }
        public void Then_an_LegalEntityAlreadyExistsException_is_raised_if_the_same_legalEntity_has_already_been_added()
        {
            // Arrange
            var acountLegalEntity = _fixture.Create <long>();

            _sut.AddLegalEntity(acountLegalEntity, LegalEntity.Create(_fixture.Create <LegalEntityModel>()));

            // Act
            Action action = () => _sut.AddLegalEntity(acountLegalEntity, LegalEntity.Create(_fixture.Create <LegalEntityModel>()));

            //Assert
            action.Should().Throw <LegalEntityAlreadyExistsException>().WithMessage("Legal entity has already been added");
        }
예제 #8
0
        public void Then_signed_version_is_set(int?currentVersion, int signedVersion, int minimumRequiredVersion, int?expectedVersion)
        {
            // Arrange
            var model = _fixture.Build <LegalEntityModel>()
                        .With(x => x.SignedAgreementVersion, currentVersion)
                        .Create();

            var legalEntity = LegalEntity.Create(model);

            // Act
            legalEntity.SignedAgreement(signedVersion, minimumRequiredVersion);

            // Assert
            model.SignedAgreementVersion.Should().Be(expectedVersion);
        }
        public void Then_no_legalEntities_are_unchanged_if_it_does_not_exist()
        {
            // Arrange
            var legalEntityModel = _fixture.Create <LegalEntityModel>();
            var legalEntity      = LegalEntity.Create(legalEntityModel);

            _sut.LegalEntities.Count.Should().Be(2);
            _sut.LegalEntities.SingleOrDefault(i => i.GetModel().AccountLegalEntityId == legalEntityModel.AccountLegalEntityId).Should().BeNull();

            // Act
            _sut.RemoveLegalEntity(legalEntity);

            // Assert
            _sut.LegalEntities.Count.Should().Be(2);
            _sut.LegalEntities.SingleOrDefault(i => i.GetModel().AccountLegalEntityId == legalEntityModel.AccountLegalEntityId).Should().BeNull();
        }
        public void Then_the_legalEntity_is_added_if_it_is_different_to_a_previously_added_one()
        {
            // Arrange
            var firstAccountLegalEntityId = _fixture.Create <long>();
            var firstLegalEntity          = LegalEntity.Create(_fixture.Build <LegalEntityModel>().With(f => f.AccountLegalEntityId, firstAccountLegalEntityId).Create());

            _sut.AddLegalEntity(firstAccountLegalEntityId, firstLegalEntity);

            var secondAccountLegalEntityId = firstAccountLegalEntityId + 1;
            var secondLegalEntity          = LegalEntity.Create(_fixture.Build <LegalEntityModel>().With(f => f.Id, firstLegalEntity.Id + 1).With(f => f.AccountLegalEntityId, secondAccountLegalEntityId).Create());

            // Act
            _sut.AddLegalEntity(secondAccountLegalEntityId, secondLegalEntity);

            // Assert
            _sut.LegalEntities.Should().Contain(new [] { firstLegalEntity, secondLegalEntity });
        }
        public void Then_the_model_is_returned()
        {
            // Arrange
            var legalEntityModel = _fixture.Create <LegalEntityModel>();
            var accountModel     = _fixture
                                   .Build <AccountModel>()
                                   .With(f => f.LegalEntityModels,
                                         new Collection <LegalEntityModel> {
                _fixture.Create <LegalEntityModel>(),
                legalEntityModel,
                _fixture.Create <LegalEntityModel>()
            })
                                   .Create();

            var sut = Account.Create(accountModel);

            // Act
            var model = sut.GetLegalEntity(legalEntityModel.AccountLegalEntityId);

            // Assert
            model.Should().Be(LegalEntity.Create(legalEntityModel));
        }
예제 #12
0
 public static LegalEntity Map(this LegalEntityModel model)
 {
     return(LegalEntity.Create(model));
 }