Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions TransactionProcessor.DatabaseTests/ContractEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task AddOperator_OperatorIsAdded()
}

[Fact]
public async Task AddOperator_OperatorIsAdded_EventReplayHandled()
public async Task AddOperator_EventReplayHandled()
{
Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
Expand All @@ -46,7 +46,7 @@ public async Task AddContract_ContractIsAdded() {
}

[Fact]
public async Task AddContract_ContractIsAdded_EventReplayHandled() {
public async Task AddContract_EventReplayHandled() {
Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();

Expand All @@ -70,7 +70,7 @@ public async Task AddContractProduct_ContractProductIsAdded() {
}

[Fact]
public async Task AddContractProduct_ContractProductIsAdded_EventReplayHandled() {
public async Task AddContractProduct_EventReplayHandled() {
Result result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
EstateManagementContext context = this.GetContext();
Expand Down Expand Up @@ -102,7 +102,7 @@ public async Task AddContractProductTransactionFee_ContractIsAdded()
}

[Fact]
public async Task AddContractProductTransactionFee_ContractIsAdded_EventReplayHandled()
public async Task AddContractProductTransactionFee_EventReplayHandled()
{
Result result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
Expand All @@ -122,7 +122,7 @@ public async Task AddFileImportLog_FileImportLogIsAdded()
}

[Fact]
public async Task AddFileImportLog_FileImportLogIsAdded_EventReplayHandled()
public async Task AddFileImportLog_EventReplayHandled()
{
Result result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
Expand Down Expand Up @@ -150,5 +150,26 @@ public async Task AddFileImportLogFile_EventReplayHandled()
result = await this.Repository.AddFileToImportLog(TestData.DomainEvents.FileAddedToImportLogEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
}


[Fact]
public async Task AddEstate_EstateIsAdded()
{
Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
EstateManagementContext context = this.GetContext();
var estate = await context.Estates.SingleOrDefaultAsync(f => f.EstateId == TestData.DomainEvents.EstateCreatedEvent.EstateId);
estate.ShouldNotBeNull();
}

[Fact]
public async Task AddEstate_EventReplayHandled()
{
Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();

result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ public async Task<Result> AddEstate(EstateDomainEvents.EstateCreatedEvent domain
};
await context.Estates.AddAsync(estate, cancellationToken);

return await context.SaveChangesAsync(cancellationToken);
return await context.SaveChangesWithDuplicateHandling(cancellationToken);
}

public async Task<Result> AddEstateSecurityUser(EstateDomainEvents.SecurityUserAddedToEstateEvent domainEvent,
Expand Down
Loading