From c9564b1accbc99a5d581f463c4acc4e10491a846 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 09:36:13 +0000 Subject: [PATCH 1/2] Initial plan From 7941d3f6ec9ded5e8fa1bb5d91be81752a39d54d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 09:48:44 +0000 Subject: [PATCH 2/2] Add missing test coverage for Float Domain service methods Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- .../Services/FloatDomainServiceTests.cs | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs index 5dc88ca4..cefd7fb2 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs @@ -166,5 +166,129 @@ public async Task FloatDomainService_RecordCreditPurchase_FloatActivity_Exceptio Result result = await this.FloatDomainService.RecordCreditPurchase(command, CancellationToken.None); result.IsFailed.ShouldBeTrue(); } + + [Fact] + public async Task FloatDomainService_CreateFloatForContractProduct_GetFloatFailed() + { + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(Models.Contract.CalculationType.Fixed, Models.Contract.FeeType.Merchant))); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + FloatCommands.CreateFloatForContractProductCommand command = new FloatCommands.CreateFloatForContractProductCommand(TestData.EstateId, TestData.ContractId, + TestData.ProductId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloatForContractProduct(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_CreateFloatForContractProduct_SaveFailed() + { + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(Models.Contract.CalculationType.Fixed, Models.Contract.FeeType.Merchant))); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetEmptyFloatAggregate())); + this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + FloatCommands.CreateFloatForContractProductCommand command = new FloatCommands.CreateFloatForContractProductCommand(TestData.EstateId, TestData.ContractId, + TestData.ProductId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloatForContractProduct(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_CreateFloatForContractProduct_ExceptionThrown() + { + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(Models.Contract.CalculationType.Fixed, Models.Contract.FeeType.Merchant))); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetEmptyFloatAggregate())); + this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); + + FloatCommands.CreateFloatForContractProductCommand command = new FloatCommands.CreateFloatForContractProductCommand(TestData.EstateId, TestData.ContractId, + TestData.ProductId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloatForContractProduct(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_RecordCreditPurchase_GetFloatFailed() + { + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + FloatCommands.RecordCreditPurchaseForFloatCommand command = new FloatCommands.RecordCreditPurchaseForFloatCommand(TestData.EstateId, + TestData.FloatAggregateId, TestData.FloatCreditAmount, TestData.FloatCreditCostPrice, + TestData.CreditPurchasedDateTime); + Result result = await this.FloatDomainService.RecordCreditPurchase(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_RecordCreditPurchase_FloatActivity_GetFloatActivityFailed() + { + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + FloatActivityCommands.RecordCreditPurchaseCommand command = new FloatActivityCommands.RecordCreditPurchaseCommand(TestData.EstateId, + TestData.FloatAggregateId, TestData.CreditPurchasedDateTime, TestData.FloatCreditAmount, TestData.FloatCreditId); + Result result = await this.FloatDomainService.RecordCreditPurchase(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_RecordTransaction_TransactionRecorded() + { + FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(TestData.FloatAggregateId); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetCompletedAuthorisedSaleTransactionAggregate())); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(floatActivityAggregate)); + this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); + + FloatActivityCommands.RecordTransactionCommand command = new FloatActivityCommands.RecordTransactionCommand(TestData.EstateId, TestData.TransactionId); + Result result = await this.FloatDomainService.RecordTransaction(command, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_RecordTransaction_GetTransactionFailed() + { + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + FloatActivityCommands.RecordTransactionCommand command = new FloatActivityCommands.RecordTransactionCommand(TestData.EstateId, TestData.TransactionId); + Result result = await this.FloatDomainService.RecordTransaction(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_RecordTransaction_GetFloatActivityFailed() + { + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetCompletedAuthorisedSaleTransactionAggregate())); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + FloatActivityCommands.RecordTransactionCommand command = new FloatActivityCommands.RecordTransactionCommand(TestData.EstateId, TestData.TransactionId); + Result result = await this.FloatDomainService.RecordTransaction(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_RecordTransaction_SaveFailed() + { + FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(TestData.FloatAggregateId); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetCompletedAuthorisedSaleTransactionAggregate())); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(floatActivityAggregate)); + this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + FloatActivityCommands.RecordTransactionCommand command = new FloatActivityCommands.RecordTransactionCommand(TestData.EstateId, TestData.TransactionId); + Result result = await this.FloatDomainService.RecordTransaction(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task FloatDomainService_RecordTransaction_ExceptionThrown() + { + FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(TestData.FloatAggregateId); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetCompletedAuthorisedSaleTransactionAggregate())); + this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(floatActivityAggregate)); + this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); + + FloatActivityCommands.RecordTransactionCommand command = new FloatActivityCommands.RecordTransactionCommand(TestData.EstateId, TestData.TransactionId); + Result result = await this.FloatDomainService.RecordTransaction(command, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } } }