public void EstateAggregate_Create_EstateAlreadyCreated_ErrorThrown() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); InvalidOperationException exception = Should.Throw <InvalidOperationException>(() => { aggregate.Create(TestData.EstateName); }); exception.Message.ShouldContain($"Estate with name {TestData.EstateName} has already been created"); }
public void EstateAggregate_AddSecurityUserToEstate_SecurityUserIsAdded() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); aggregate.AddSecurityUser(TestData.SecurityUserId, TestData.EstateUserEmailAddress); }
public void EstateAggregate_AddOperatorToEstate_OperatorIsAdded() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); aggregate.AddOperator(TestData.OperatorId, TestData.OperatorName, TestData.RequireCustomMerchantNumberFalse, TestData.RequireCustomTerminalNumberFalse); }
public void EstateAggregate_Create_InvalidEstateName_ErrorThrown(String estateName) { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); ArgumentNullException exception = Should.Throw <ArgumentNullException>(() => { aggregate.Create(estateName); }); exception.Message.ShouldContain("Estate name must be provided when registering a new estate"); }
public void EstateAggregate_Create_IsCreated() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); aggregate.AggregateId.ShouldBe(TestData.EstateId); aggregate.EstateName.ShouldBe(TestData.EstateName); aggregate.IsCreated.ShouldBeTrue(); }
/// <summary> /// Creates the estate. /// </summary> /// <param name="estateId">The estate identifier.</param> /// <param name="estateName">Name of the estate.</param> /// <param name="cancellationToken">The cancellation token.</param> public async Task CreateEstate(Guid estateId, String estateName, CancellationToken cancellationToken) { EstateAggregate estateAggregate = await this.EstateAggregateRepository.GetLatestVersion(estateId, cancellationToken); estateAggregate.Create(estateName); await this.EstateAggregateRepository.SaveChanges(estateAggregate, cancellationToken); }
public void EstateAggregate_AddSecurityUserToEstate_EstateNotCreated_ErrorThrown() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); InvalidOperationException exception = Should.Throw <InvalidOperationException>(() => { aggregate.AddSecurityUser(TestData.SecurityUserId, TestData.EstateUserEmailAddress); }); exception.Message.ShouldContain("Estate has not been created"); }
public void EstateAggregate_AddOperatorToEstate_EstateNotCreated_ErrorThrown() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); InvalidOperationException exception = Should.Throw <InvalidOperationException>(() => { aggregate.AddOperator(TestData.OperatorId, TestData.OperatorName, TestData.RequireCustomMerchantNumberFalse, TestData.RequireCustomTerminalNumberFalse); }); exception.Message.ShouldContain("Estate has not been created"); }
public void EstateAggregate_GetEstate_NoOperators_EstateIsReturned() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); Estate model = aggregate.GetEstate(); model.EstateId.ShouldBe(TestData.EstateId); model.Name.ShouldBe(TestData.EstateName); model.Operators.ShouldBeNull(); }
public void EstateAggregate_AddOperatorToEstate_OperatorWithNameAlreadyAdded_ErrorThrown() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); aggregate.AddOperator(TestData.OperatorId, TestData.OperatorName, TestData.RequireCustomMerchantNumberFalse, TestData.RequireCustomTerminalNumberFalse); InvalidOperationException exception = Should.Throw <InvalidOperationException>(() => { aggregate.AddOperator(TestData.OperatorId2, TestData.OperatorName, TestData.RequireCustomMerchantNumberFalse, TestData.RequireCustomTerminalNumberFalse); }); exception.Message.ShouldContain($"Duplicate operator details are not allowed, an operator already exists on this estate with Name [{TestData.OperatorName}]"); }
public void EstateAggregate_GetEstate_WithASecurityUser_EstateIsReturned() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); aggregate.AddSecurityUser(TestData.SecurityUserId, TestData.EstateUserEmailAddress); Estate model = aggregate.GetEstate(); model.EstateId.ShouldBe(TestData.EstateId); model.Name.ShouldBe(TestData.EstateName); model.SecurityUsers.ShouldHaveSingleItem(); SecurityUser securityUser = model.SecurityUsers.Single(); securityUser.SecurityUserId.ShouldBe(TestData.SecurityUserId); securityUser.EmailAddress.ShouldBe(TestData.EstateUserEmailAddress); }
public void EstateAggregate_GetEstate_WithAnOperator_EstateIsReturned() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.Create(TestData.EstateName); aggregate.AddOperator(TestData.OperatorId, TestData.OperatorName, TestData.RequireCustomMerchantNumberFalse, TestData.RequireCustomTerminalNumberFalse); Estate model = aggregate.GetEstate(); model.EstateId.ShouldBe(TestData.EstateId); model.Name.ShouldBe(TestData.EstateName); model.Operators.ShouldHaveSingleItem(); Operator @operator = model.Operators.Single(); @operator.OperatorId.ShouldBe(TestData.OperatorId); @operator.Name.ShouldBe(TestData.OperatorName); @operator.RequireCustomMerchantNumber.ShouldBe(TestData.RequireCustomMerchantNumberFalse); @operator.RequireCustomTerminalNumber.ShouldBe(TestData.RequireCustomTerminalNumberFalse); }
public void EstateAggregate_CanBeCreated_IsCreated() { EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); aggregate.AggregateId.ShouldBe(TestData.EstateId); }