From 64726c72756793224b0f2801eb63ce5946c9d663 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 13:39:39 +0000 Subject: [PATCH 1/3] Initial plan From a3d056bfc85a3057d34735c8b435549b788784d2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 13:55:43 +0000 Subject: [PATCH 2/3] Add missing test cases for MerchantStatementDomainService Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- .../MerchantStatementDomainServiceTests.cs | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs index 3ce2a336..982b1627 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs @@ -282,5 +282,117 @@ public async Task MerchantStatementDomainService_EmailStatement_GetTokenFailed_S result.IsFailed.ShouldBeTrue(); } + [Fact] + public async Task MerchantStatementDomainService_AddTransactionToStatement_GetStatementForDateFailed_TransactionNotAddedToStatement() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddSettledFeeToStatement_GetStatementForDateFailed_SettledFeeNotAddedToStatement() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddDepositToStatement_SaveFailed_DepositNotAddedToStatement() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantStatementForDateAggregate)); + this.AggregateService.Setup(a => a.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); + Result result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddDepositToStatement_GetStatementForDateFailed_DepositNotAddedToStatement() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddWithdrawalToStatement_SaveFailed_WithdrawalNotAddedToStatement() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantStatementForDateAggregate)); + this.AggregateService.Setup(a => a.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); + Result result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddWithdrawalToStatement_GetStatementForDateFailed_WithdrawalNotAddedToStatement() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_RecordActivityDateOnMerchantStatement_GetStatementFailed_ActivityDateNotRecorded() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_GenerateStatement_GetStatementFailed_StatementIsNotGenerated() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_BuildStatement_GetStatementFailed_StatementIsNotBuilt() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_BuildStatement_GetStatementHtmlFailed_StatementIsNotBuilt() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.GeneratedMerchantStatementAggregate())); + this.AggregateService.Setup(a => a.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + + this.AggregateService.Setup(a => a.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate))); + + this.StatementBuilder.Setup(s => s.GetStatementHtml(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_EmailStatement_GetStatementFailed_StatementIsNotEmailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_EmailStatement_SaveFailed_StatementIsNotEmailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.BuiltMerchantStatementAggregate())); + this.AggregateService.Setup(a => a.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); + + this.AggregateService.Setup(a => a.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate))); + + this.MessagingServiceClient.Setup(m => m.SendEmail(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + + this.SecurityServiceClient.Setup(m => m.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); + + Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + } \ No newline at end of file From 9059e6870816e18d82ae7e99dad554db4045077c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 14:03:44 +0000 Subject: [PATCH 3/3] Add exception test cases for each MerchantStatementDomainService method Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- .../MerchantStatementDomainServiceTests.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs index 982b1627..41326060 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs @@ -394,5 +394,69 @@ public async Task MerchantStatementDomainService_EmailStatement_SaveFailed_State result.IsFailed.ShouldBeTrue(); } + [Fact] + public async Task MerchantStatementDomainService_AddTransactionToStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddSettledFeeToStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddDepositToStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_AddWithdrawalToStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_RecordActivityDateOnMerchantStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_GenerateStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_BuildStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task MerchantStatementDomainService_EmailStatement_ExceptionThrown_ResultIsFailed() + { + this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception("Test exception")); + Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + } \ No newline at end of file