diff --git a/NuGet.Config b/NuGet.Config
index 3086e202..66b50e02 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -6,7 +6,7 @@
-
+
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)
{