From 48a8ce3459999aeb37833d4b98161beba92fe172 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:50:52 +0000 Subject: [PATCH 1/3] Initial plan From b9595a24be28c683f074355169543f45cdbff08c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 16:03:55 +0000 Subject: [PATCH 2/3] Initial plan for VoucherDomainService test coverage Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 3086e202..66b50e02 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -6,7 +6,7 @@ - + From 234f86782d1a18de4c109add0d25b0903b7bc32a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Feb 2026 16:09:47 +0000 Subject: [PATCH 3/3] Add missing test cases to VoucherDomainServiceTests for improved coverage Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com> --- .../Services/VoucherDomainServiceTests.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs index a78babc1..4e595170 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs @@ -193,6 +193,69 @@ public async Task VoucherDomainService_RedeemVoucher_VoucherNotFound_ErrorThrown CancellationToken.None); result.IsFailed.ShouldBeTrue(); } + + [Fact] + public async Task VoucherDomainService_IssueVoucher_GetVoucherFailed_ErrorThrown() { + this.AggregateService.Setup(v => v.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); + + Result result = await this.VoucherDomainService.IssueVoucher(TestData.IssueVoucherCommand, + CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task VoucherDomainService_IssueVoucher_SaveFailed_ErrorThrown() { + this.AggregateService.Setup(v => v.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new VoucherAggregate())); + this.AggregateService.Setup(v => v.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); + + Result result = await this.VoucherDomainService.IssueVoucher(TestData.IssueVoucherCommand, + CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task VoucherDomainService_RedeemVoucher_GetVoucherAggregateFailed_ErrorThrown() { + this.AggregateService.Setup(v => v.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + + this.Context.VoucherProjectionStates.Add(new TransactionProcessor.Database.Entities.VoucherProjectionState() { + VoucherCode = TestData.VoucherCode, + OperatorIdentifier = TestData.OperatorIdentifier, + Barcode = TestData.Barcode, + Timestamp = BitConverter.GetBytes(DateTime.UtcNow.Ticks) + }); + await this.Context.SaveChangesAsync(); + + Result result = await this.VoucherDomainService.RedeemVoucher(TestData.EstateId, + TestData.VoucherCode, + TestData.RedeemedDateTime, + CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task VoucherDomainService_RedeemVoucher_SaveFailed_ErrorThrown() { + this.AggregateService.Setup(v => v.GetLatest(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.GetVoucherAggregateWithRecipientMobile())); + this.AggregateService.Setup(v => v.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + + this.Context.VoucherProjectionStates.Add(new TransactionProcessor.Database.Entities.VoucherProjectionState() { + VoucherCode = TestData.VoucherCode, + OperatorIdentifier = TestData.OperatorIdentifier, + Barcode = TestData.Barcode, + Timestamp = BitConverter.GetBytes(DateTime.UtcNow.Ticks) + }); + await this.Context.SaveChangesAsync(); + + Result result = await this.VoucherDomainService.RedeemVoucher(TestData.EstateId, + TestData.VoucherCode, + TestData.RedeemedDateTime, + CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } private EstateManagementContext GetContext(String databaseName) {