diff --git a/Directory.Packages.props b/Directory.Packages.props index 5e199922..8ff98f4f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,6 +1,7 @@ true + $(NoWarn);NU1507 @@ -101,4 +102,4 @@ - \ No newline at end of file + diff --git a/NuGet.Config b/NuGet.Config index 66b50e02..eeaf9358 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -4,6 +4,22 @@ + + + + + + + + + + + + + + + + diff --git a/TransactionProcessor.Aggregates.Tests/FloatAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/FloatAggregateTests.cs index 7f5ac511..460e20ca 100644 --- a/TransactionProcessor.Aggregates.Tests/FloatAggregateTests.cs +++ b/TransactionProcessor.Aggregates.Tests/FloatAggregateTests.cs @@ -23,22 +23,20 @@ public void FloatAggregate_CanBeCreated_IsCreated() public void FloatAggregate_CreateFloat_IsCreated() { Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); - Result result = aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + Result result = aggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); result.IsSuccess.ShouldBeTrue(); aggregate.AggregateId.ShouldBe(TestData.FloatAggregateId); aggregate.EstateId.ShouldBe(TestData.EstateId); - aggregate.ContractId.ShouldBe(TestData.ContractId); - aggregate.ProductId.ShouldBe(TestData.ProductId); aggregate.CreatedDateTime.ShouldBe(TestData.FloatCreatedDateTime); } [Fact] public void FloatAggregate_CreateFloat_FloatAlreadyCreated_NoErrorThrown() { Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); - aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + aggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); - Result result = aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + Result result = aggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); result.IsSuccess.ShouldBeTrue(); } @@ -46,7 +44,7 @@ public void FloatAggregate_CreateFloat_FloatAlreadyCreated_NoErrorThrown() { public void FloatAggregate_RecordCreditPurchase_CreditPurchaseIsRecorded() { Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); - aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + aggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); Result result = aggregate.RecordCreditPurchase(DateTime.Now, 1000, 900); result.IsSuccess.ShouldBeTrue(); aggregate.NumberOfCreditPurchases.ShouldBe(1); @@ -70,7 +68,7 @@ public void FloatAggregate_RecordCreditPurchase_FloatNotCreated_ErrorThrown() public void FloatAggregate_RecordCreditPurchase_MultipleCreditPurchases_AllCreditPurchasesAreRecorded() { Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); - aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + aggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); aggregate.RecordCreditPurchase(DateTime.Now, 1000, 900); aggregate.NumberOfCreditPurchases.ShouldBe(1); @@ -103,7 +101,7 @@ public void FloatAggregate_RecordCreditPurchase_MultipleCreditPurchases_AllCredi public void FloatAggregate_RecordCreditPurchase_DuplicateCreditPurchase_ErrorThrown() { Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); - aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + aggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); DateTime purchaseDateTime = DateTime.Now; aggregate.RecordCreditPurchase(purchaseDateTime, 1000, 900); @@ -118,7 +116,7 @@ public void FloatAggregate_RecordCreditPurchase_DuplicateCreditPurchase_ErrorThr public void FloatAggregate_GetTotalCostPrice_TotalCostReturned() { Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); - aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + aggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); DateTime purchaseDateTime = DateTime.Now; aggregate.RecordCreditPurchase(purchaseDateTime, 1000, 900); diff --git a/TransactionProcessor.Aggregates/FloatAggregate.cs b/TransactionProcessor.Aggregates/FloatAggregate.cs index 368e6b6a..14ad61e8 100644 --- a/TransactionProcessor.Aggregates/FloatAggregate.cs +++ b/TransactionProcessor.Aggregates/FloatAggregate.cs @@ -9,11 +9,16 @@ namespace TransactionProcessor.Aggregates { public static class FloatAggregateExtensions { + public static void PlayEvent(this FloatAggregate aggregate, FloatDomainEvents.FloatCreatedEvent domainEvent) + { + aggregate.EstateId = domainEvent.EstateId; + aggregate.CreatedDateTime = domainEvent.CreatedDateTime; + aggregate.IsCreated = true; + } + public static void PlayEvent(this FloatAggregate aggregate, FloatDomainEvents.FloatCreatedForContractProductEvent domainEvent) { aggregate.EstateId = domainEvent.EstateId; - aggregate.ContractId = domainEvent.ContractId; - aggregate.ProductId = domainEvent.ProductId; aggregate.CreatedDateTime = domainEvent.CreatedDateTime; aggregate.IsCreated = true; } @@ -29,18 +34,16 @@ public static void PlayEvent(this FloatAggregate aggregate, FloatDomainEvents.Fl public static Result CreateFloat(this FloatAggregate aggregate, Guid estateId, - Guid contractId, - Guid productId, DateTime createdDateTime) { if (aggregate.IsCreated) { return Result.Success(); // Idempotent } - FloatDomainEvents.FloatCreatedForContractProductEvent floatCreatedForContractProductEvent = new(aggregate.AggregateId, - estateId, contractId, productId, createdDateTime); + FloatDomainEvents.FloatCreatedEvent floatCreatedEvent = new(aggregate.AggregateId, + estateId, createdDateTime); - aggregate.ApplyAndAppend(floatCreatedForContractProductEvent); + aggregate.ApplyAndAppend(floatCreatedEvent); return Result.Success(); } @@ -129,9 +132,6 @@ private FloatAggregate(Guid aggregateId) public Boolean IsCreated { get; internal set; } public Guid EstateId { get; internal set; } - - public Guid ContractId { get; internal set; } - public Guid ProductId { get; internal set; } public DateTime CreatedDateTime { get; internal set; } public Int32 NumberOfCreditPurchases { get; internal set; } diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ContractDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ContractDomainEventHandlerTests.cs index 940c6fee..6600901f 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ContractDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ContractDomainEventHandlerTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shared.Logger; using Shared.Serialisation; using Shouldly; @@ -32,7 +32,7 @@ public void ContractDomainEventHandler_ContractCreatedEvent_EventIsHandled() { ContractDomainEvents.ContractCreatedEvent contractCreatedEvent = TestData.DomainEvents.ContractCreatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(contractCreatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(contractCreatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -40,7 +40,7 @@ public void ContractDomainEventHandler_FixedValueProductAddedToContractEvent_Eve { ContractDomainEvents.FixedValueProductAddedToContractEvent fixedValueProductAddedToContractEvent = TestData.DomainEvents.FixedValueProductAddedToContractEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(fixedValueProductAddedToContractEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(fixedValueProductAddedToContractEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -48,7 +48,7 @@ public void ContractDomainEventHandler_TransactionFeeForProductAddedToContractEv { ContractDomainEvents.TransactionFeeForProductAddedToContractEvent transactionFeeForProductAddedToContractEvent = TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(transactionFeeForProductAddedToContractEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(transactionFeeForProductAddedToContractEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -56,7 +56,7 @@ public void ContractDomainEventHandler_TransactionFeeForProductDisabledEvent_Eve { ContractDomainEvents.TransactionFeeForProductDisabledEvent transactionFeeForProductDisabledEvent = TestData.DomainEvents.TransactionFeeForProductDisabledEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(transactionFeeForProductDisabledEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(transactionFeeForProductDisabledEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -64,8 +64,8 @@ public void ContractDomainEventHandler_VariableValueProductAddedToContractEvent_ { ContractDomainEvents.VariableValueProductAddedToContractEvent variableValueProductAddedToContractEvent = TestData.DomainEvents.VariableValueProductAddedToContractEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(variableValueProductAddedToContractEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(variableValueProductAddedToContractEvent, TestContext.Current.CancellationToken); }); } #endregion -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/EstateDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/EstateDomainEventHandlerTests.cs index 232a9b05..6ecf4946 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/EstateDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/EstateDomainEventHandlerTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shared.Logger; using Shared.Serialisation; using Shouldly; @@ -38,7 +38,7 @@ public void EstateDomainEventHandler_EstateCreatedEvent_EventIsHandled() .Setup(r => r.CreateReadModel(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(estateCreatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(estateCreatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -49,7 +49,7 @@ public async Task EstateDomainEventHandler_EstateCreatedEvent_CreateReadModelFai .Setup(r => r.CreateReadModel(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure); - Result result = await this.DomainEventHandler.Handle(estateCreatedEvent, CancellationToken.None); + Result result = await this.DomainEventHandler.Handle(estateCreatedEvent, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -58,7 +58,7 @@ public void EstateDomainEventHandler_EstateReferenceAllocatedEvent_EventIsHandle { EstateDomainEvents.EstateReferenceAllocatedEvent estateReferenceAllocatedEvent = TestData.DomainEvents.EstateReferenceAllocatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(estateReferenceAllocatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(estateReferenceAllocatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -66,8 +66,8 @@ public void EstateDomainEventHandler_SecurityUserAddedEvent_EventIsHandled() { EstateDomainEvents.SecurityUserAddedToEstateEvent securityUserAddedEvent = TestData.DomainEvents.EstateSecurityUserAddedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(securityUserAddedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(securityUserAddedEvent, TestContext.Current.CancellationToken); }); } #endregion -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantDomainEventHandlerTests.cs index b81d6e37..3bfecd01 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantDomainEventHandlerTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; using MediatR; @@ -40,7 +40,7 @@ public async Task MerchantDomainEventHandler_Handle_CallbackReceivedEnrichedEven this.Mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); CallbackReceivedEnrichedEvent domainEvent = TestData.DomainEvents.CallbackReceivedEnrichedEventDeposit; - var result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + var result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -50,7 +50,7 @@ public async Task MerchantDomainEventHandler_Handle_CallbackReceivedEnrichedEven { CallbackReceivedEnrichedEvent domainEvent = TestData.DomainEvents.CallbackReceivedEnrichedEventOtherType; - var result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + var result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -62,7 +62,7 @@ public async Task MerchantDomainEventHandler_Handle_CallbackReceivedEnrichedEven CallbackReceivedEnrichedEvent domainEvent = TestData.DomainEvents.CallbackReceivedEnrichedEventDeposit; - var result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + var result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -74,7 +74,7 @@ public void MerchantDomainEventHandler_AddressAddedEvent_EventIsHandled() { MerchantDomainEvents.AddressAddedEvent addressAddedEvent = TestData.DomainEvents.AddressAddedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(addressAddedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(addressAddedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -82,7 +82,7 @@ public void MerchantDomainEventHandler_ContactAddedEvent_EventIsHandled() { MerchantDomainEvents.ContactAddedEvent contactAddedEvent = TestData.DomainEvents.ContactAddedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(contactAddedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(contactAddedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -90,7 +90,7 @@ public void MerchantDomainEventHandler_MerchantReferenceAllocatedEvent_EventIsHa { MerchantDomainEvents.MerchantReferenceAllocatedEvent merchantReferenceAllocatedEvent = TestData.DomainEvents.MerchantReferenceAllocatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(merchantReferenceAllocatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(merchantReferenceAllocatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -98,7 +98,7 @@ public void MerchantDomainEventHandler_DeviceAddedToMerchantEvent_EventIsHandled { MerchantDomainEvents.DeviceAddedToMerchantEvent deviceAddedToMerchantEvent = TestData.DomainEvents.DeviceAddedToMerchantEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(deviceAddedToMerchantEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(deviceAddedToMerchantEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -106,7 +106,7 @@ public void MerchantDomainEventHandler_MerchantCreatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantCreatedEvent merchantCreatedEvent = TestData.DomainEvents.MerchantCreatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(merchantCreatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(merchantCreatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -114,7 +114,7 @@ public void MerchantDomainEventHandler_OperatorAssignedToMerchantEvent_EventIsHa { MerchantDomainEvents.OperatorAssignedToMerchantEvent operatorAssignedToMerchantEvent = TestData.DomainEvents.OperatorAssignedToMerchantEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorAssignedToMerchantEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorAssignedToMerchantEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -122,7 +122,7 @@ public void MerchantDomainEventHandler_SecurityUserAddedEvent_EventIsHandled() { MerchantDomainEvents.SecurityUserAddedToMerchantEvent merchantSecurityUserAddedEvent = TestData.DomainEvents.MerchantSecurityUserAddedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(merchantSecurityUserAddedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(merchantSecurityUserAddedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -130,7 +130,7 @@ public void MerchantDomainEventHandler_SettlementScheduleChangedEvent_EventIsHan { MerchantDomainEvents.SettlementScheduleChangedEvent settlementScheduleChangedEvent = TestData.DomainEvents.SettlementScheduleChangedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(settlementScheduleChangedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(settlementScheduleChangedEvent, TestContext.Current.CancellationToken); }); } [Fact(Skip = "No event yet")] @@ -138,7 +138,7 @@ public void MerchantDomainEventHandler_SettlementGeneratedEvent_EventIsHandled() { //StatementGeneratedEvent statementGeneratedEvent = TestData.StatementGeneratedEvent; - //Should.NotThrow(async () => { await this.DomainEventHandler.Handle(statementGeneratedEvent, CancellationToken.None); }); + //Should.NotThrow(async () => { await this.DomainEventHandler.Handle(statementGeneratedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -146,7 +146,7 @@ public void MerchantDomainEventHandler_TransactionHasBeenCompletedEvent_EventIsH { TransactionDomainEvents.TransactionHasBeenCompletedEvent domainEvent = TestData.DomainEvents.TransactionHasBeenCompletedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -154,7 +154,7 @@ public void MerchantDomainEventHandler_MerchantNameUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantNameUpdatedEvent domainEvent = TestData.DomainEvents.MerchantNameUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -162,91 +162,91 @@ public void MerchantDomainEventHandler_DeviceSwappedForMerchantEvent_EventIsHand { MerchantDomainEvents.DeviceSwappedForMerchantEvent domainEvent = TestData.DomainEvents.DeviceSwappedForMerchantEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_OperatorRemovedFromMerchantEvent_EventIsHandled() { MerchantDomainEvents.OperatorRemovedFromMerchantEvent domainEvent = TestData.DomainEvents.OperatorRemovedFromMerchantEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantAddressLine1UpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantAddressLine1UpdatedEvent domainEvent = TestData.DomainEvents.MerchantAddressLine1UpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantAddressLine2UpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantAddressLine2UpdatedEvent domainEvent = TestData.DomainEvents.MerchantAddressLine2UpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantAddressLine3UpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantAddressLine3UpdatedEvent domainEvent = TestData.DomainEvents.MerchantAddressLine3UpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantAddressLine4UpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantAddressLine4UpdatedEvent domainEvent = TestData.DomainEvents.MerchantAddressLine4UpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantCountyUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantCountyUpdatedEvent domainEvent = TestData.DomainEvents.MerchantCountyUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantRegionUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantRegionUpdatedEvent domainEvent = TestData.DomainEvents.MerchantRegionUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantTownUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantTownUpdatedEvent domainEvent = TestData.DomainEvents.MerchantTownUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantPostalCodeUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantPostalCodeUpdatedEvent domainEvent = TestData.DomainEvents.MerchantPostalCodeUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantContactNameUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantContactNameUpdatedEvent domainEvent = TestData.DomainEvents.MerchantContactNameUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantContactEmailAddressUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantContactEmailAddressUpdatedEvent domainEvent = TestData.DomainEvents.MerchantContactEmailAddressUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] public void MerchantDomainEventHandler_MerchantContactPhoneNumberUpdatedEvent_EventIsHandled() { MerchantDomainEvents.MerchantContactPhoneNumberUpdatedEvent domainEvent = TestData.DomainEvents.MerchantContactPhoneNumberUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -254,7 +254,7 @@ public void MerchantDomainEventHandler_ContractAddedToMerchantEvent_EventIsHandl { MerchantDomainEvents.ContractAddedToMerchantEvent domainEvent = TestData.DomainEvents.ContractAddedToMerchantEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -262,9 +262,10 @@ public void MerchantDomainEventHandler_EstateCreatedEvent_EventIsHandled() { EstateDomainEvents.EstateCreatedEvent domainEvent = TestData.DomainEvents.EstateCreatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); }); } #endregion } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantScheduleDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantScheduleDomainEventHandlerTests.cs index 0732e1c3..b4f1af5f 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantScheduleDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantScheduleDomainEventHandlerTests.cs @@ -35,7 +35,7 @@ public async Task MerchantScheduleDomainEventHandler_MerchantScheduleCreatedEven .Setup(r => r.AddMerchantSchedule(domainEvent, It.IsAny())) .ReturnsAsync(Result.Success); - Result result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + Result result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.EstateReportingRepository.Verify(r => r.AddMerchantSchedule(domainEvent, It.IsAny()), Times.Once); @@ -49,9 +49,10 @@ public async Task MerchantScheduleDomainEventHandler_MerchantScheduleMonthUpdate .Setup(r => r.UpdateMerchantSchedule(domainEvent, It.IsAny())) .ReturnsAsync(Result.Success); - Result result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + Result result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.EstateReportingRepository.Verify(r => r.UpdateMerchantSchedule(domainEvent, It.IsAny()), Times.Once); } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantStatementDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantStatementDomainEventHandlerTests.cs index 085581cf..8d6b34ac 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantStatementDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/MerchantStatementDomainEventHandlerTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -30,7 +30,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_StatementGeneratedE this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.StatementGeneratedEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.StatementGeneratedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -40,7 +40,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_StatementBuiltEvent this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.StatementBuiltEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.StatementBuiltEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -50,7 +50,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_TransactionHasBeenC this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.TransactionHasBeenCompletedEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.TransactionHasBeenCompletedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -63,7 +63,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_TransactionHasBeenC .ReturnsAsync(Result.Failure(errors)) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.TransactionHasBeenCompletedEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.TransactionHasBeenCompletedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.Mediator.Verify(m => m.Send(It.IsAny>(), It.IsAny()), Times.Exactly(2)); } @@ -80,7 +80,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_TransactionHasBeenC .ReturnsAsync(Result.Failure(errors)) .ReturnsAsync(Result.Failure(errors)); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.TransactionHasBeenCompletedEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.TransactionHasBeenCompletedEvent, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); this.Mediator.Verify(m => m.Send(It.IsAny>(), It.IsAny()), Times.Exactly(6)); } @@ -91,7 +91,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_MerchantFeeSettledE this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.MerchantFeeSettledEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.MerchantFeeSettledEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -104,7 +104,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_MerchantFeeSettledE .ReturnsAsync(Result.Failure(errors)) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.MerchantFeeSettledEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.MerchantFeeSettledEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.Mediator.Verify(m => m.Send(It.IsAny>(), It.IsAny()), Times.Exactly(2)); } @@ -121,7 +121,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_MerchantFeeSettledE .ReturnsAsync(Result.Failure(errors)) .ReturnsAsync(Result.Failure(errors)); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.MerchantFeeSettledEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.MerchantFeeSettledEvent, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); this.Mediator.Verify(m => m.Send(It.IsAny>(), It.IsAny()), Times.Exactly(6)); } @@ -132,7 +132,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_StatementCreatedFor this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.StatementCreatedForDateEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.StatementCreatedForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -142,7 +142,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_AutomaticDepositMad this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.AutomaticDepositMadeEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.AutomaticDepositMadeEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -152,7 +152,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_ManualDepositMadeEv this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.ManualDepositMadeEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.ManualDepositMadeEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -162,7 +162,7 @@ public async Task MerchantStatementDomainEventHandler_Handle_WithdrawalMadeEvent this.Mediator.Setup(m => m.Send(It.IsAny>(), It.IsAny())) .ReturnsAsync(Result.Success()); - Result result = await this.EventHandler.Handle(TestData.DomainEvents.WithdrawalMadeEvent, CancellationToken.None); + Result result = await this.EventHandler.Handle(TestData.DomainEvents.WithdrawalMadeEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/OperatorDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/OperatorDomainEventHandlerTests.cs index c5a5186c..dc12bd22 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/OperatorDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/OperatorDomainEventHandlerTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shared.Logger; using Shared.Serialisation; using Shouldly; @@ -30,7 +30,7 @@ public void OperatorDomainEventHandler_OperatorCreatedEvent_EventIsHandled() { OperatorDomainEvents.OperatorCreatedEvent operatorCreatedEvent = TestData.DomainEvents.OperatorCreatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -38,7 +38,7 @@ public void OperatorDomainEventHandler_OperatorNameUpdatedEvent_EventIsHandled() { OperatorDomainEvents.OperatorNameUpdatedEvent operatorCreatedEvent = TestData.DomainEvents.OperatorNameUpdatedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -46,7 +46,7 @@ public void OperatorDomainEventHandler_OperatorRequireCustomMerchantNumberChange { OperatorDomainEvents.OperatorRequireCustomMerchantNumberChangedEvent operatorCreatedEvent = TestData.DomainEvents.OperatorRequireCustomMerchantNumberChangedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, TestContext.Current.CancellationToken); }); } [Fact] @@ -54,6 +54,6 @@ public void OperatorDomainEventHandler_OperatorRequireCustomTerminalNumberChange { OperatorDomainEvents.OperatorRequireCustomTerminalNumberChangedEvent operatorCreatedEvent = TestData.DomainEvents.OperatorRequireCustomTerminalNumberChangedEvent; - Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, CancellationToken.None); }); + Should.NotThrow(async () => { await this.DomainEventHandler.Handle(operatorCreatedEvent, TestContext.Current.CancellationToken); }); } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ReadModelDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ReadModelDomainEventHandlerTests.cs index 733f7b93..82bb626e 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ReadModelDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/ReadModelDomainEventHandlerTests.cs @@ -49,7 +49,7 @@ public async Task ReadModelDomainEventHandler_Handle_AdditionalRequestDataRecord .Setup(r => r.SetTransactionAmount(domainEvent, It.IsAny())) .ReturnsAsync(Result.Success); - Result result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + Result result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.EstateReportingRepository.Verify(r => r.RecordTransactionAdditionalRequestData(domainEvent, It.IsAny()), Times.Once); @@ -65,7 +65,7 @@ public async Task ReadModelDomainEventHandler_Handle_StatementGeneratedEvent_Mar .Setup(r => r.MarkStatementAsGenerated(domainEvent, It.IsAny())) .ReturnsAsync(Result.Failure); - Result result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + Result result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); this.EstateReportingRepository.Verify(r => r.MarkStatementAsGenerated(domainEvent, It.IsAny()), Times.Once); @@ -77,9 +77,10 @@ public async Task ReadModelDomainEventHandler_Handle_UnhandledDomainEvent_Return { UnhandledDomainEvent domainEvent = new(); - Result result = await this.DomainEventHandler.Handle(domainEvent, CancellationToken.None); + Result result = await this.DomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.EstateReportingRepository.VerifyNoOtherCalls(); } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs index 1587d757..0325e0d5 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs @@ -1,4 +1,4 @@ -using EventStore.Client; +using EventStore.Client; using Grpc.Core; using MediatR; using SimpleResults; @@ -68,10 +68,11 @@ public async Task TransactionDomainEventHandler_EventPassedIn_EventIsHandled(Typ _ => throw new NotSupportedException($"Event {eventType.Name} not supported") }; - var result = await this.TransactionDomainEventHandler.Handle(domainEvent, CancellationToken.None); + var result = await this.TransactionDomainEventHandler.Handle(domainEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs index 8c1953f1..cf8054a3 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs @@ -1,4 +1,4 @@ -using SimpleResults; +using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Services; using TransactionProcessor.Database.Contexts; @@ -107,9 +107,9 @@ public async Task VoucherDomainEventHandler_VoucherIssuedEvent_WithEmailAddress_ EstateId = TestData.EstateId, Description = TestData.OperatorIdentifier }); - await this.Context.SaveChangesAsync(CancellationToken.None); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); - await this.VoucherDomainEventHandler.Handle(TestData.VoucherIssuedEvent, CancellationToken.None); + await this.VoucherDomainEventHandler.Handle(TestData.VoucherIssuedEvent, TestContext.Current.CancellationToken); } [Fact] @@ -132,8 +132,8 @@ public async Task VoucherDomainEventHandler_VoucherIssuedEvent_WithRecipientMobi EstateId = TestData.EstateId, Description = TestData.OperatorIdentifier }); - await this.Context.SaveChangesAsync(CancellationToken.None); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); - await VoucherDomainEventHandler.Handle(TestData.VoucherIssuedEvent, CancellationToken.None); + await VoucherDomainEventHandler.Handle(TestData.VoucherIssuedEvent, TestContext.Current.CancellationToken); } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/Manager/TransactionProcessorManagerTests.cs b/TransactionProcessor.BusinessLogic.Tests/Manager/TransactionProcessorManagerTests.cs index 74906abf..589dcd42 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Manager/TransactionProcessorManagerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Manager/TransactionProcessorManagerTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.Logger; @@ -48,7 +48,7 @@ public async Task TransactionProcessorManager_GetEstates_EstatesAreReturned() this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); this.TransactionProcessorReadModelRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); - Result> getEstatesResult = await this.TransactionProcessorManager.GetEstates(TestData.EstateId, CancellationToken.None); + Result> getEstatesResult = await this.TransactionProcessorManager.GetEstates(TestData.EstateId, TestContext.Current.CancellationToken); getEstatesResult.IsSuccess.ShouldBeTrue(); List estateModels = getEstatesResult.Data; estateModels.ShouldNotBeNull(); @@ -63,7 +63,7 @@ public async Task TransactionProcessorManager_GetEstates_RepoCallFails_ResultFai this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); this.TransactionProcessorReadModelRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result> getEstatesResult = await this.TransactionProcessorManager.GetEstates(TestData.EstateId, CancellationToken.None); + Result> getEstatesResult = await this.TransactionProcessorManager.GetEstates(TestData.EstateId, TestContext.Current.CancellationToken); getEstatesResult.IsFailed.ShouldBeTrue(); } @@ -72,9 +72,9 @@ public async Task TransactionProcessorManager_GetEstate_EstateIsReturned() { this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.TransactionProcessorReadModelRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); - this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), CancellationToken.None)).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); + this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), TestContext.Current.CancellationToken)).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); - Result getEstateResult = await this.TransactionProcessorManager.GetEstate(TestData.EstateId, CancellationToken.None); + Result getEstateResult = await this.TransactionProcessorManager.GetEstate(TestData.EstateId, TestContext.Current.CancellationToken); getEstateResult.IsSuccess.ShouldBeTrue(); Estate estateModel = getEstateResult.Data; estateModel.ShouldNotBeNull(); @@ -92,7 +92,7 @@ public async Task TransactionProcessorManager_GetEstate_InvalidEstateId_ErrorIsT this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyEstateAggregate)); this.TransactionProcessorReadModelRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); - Result getEstateResult = await this.TransactionProcessorManager.GetEstate(TestData.EstateId, CancellationToken.None); + Result getEstateResult = await this.TransactionProcessorManager.GetEstate(TestData.EstateId, TestContext.Current.CancellationToken); getEstateResult.IsFailed.ShouldBeTrue(); } @@ -102,7 +102,7 @@ public async Task TransactionProcessorManager_GetEstate_GetLatestFailed_ErrorIsT this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); this.TransactionProcessorReadModelRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); - Result getEstateResult = await this.TransactionProcessorManager.GetEstate(TestData.EstateId, CancellationToken.None); + Result getEstateResult = await this.TransactionProcessorManager.GetEstate(TestData.EstateId, TestContext.Current.CancellationToken); getEstateResult.IsFailed.ShouldBeTrue(); } @@ -111,7 +111,7 @@ public async Task TransactionProcessorManager_GetContract_ContractIsReturned() { this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(CalculationType.Fixed, FeeType.Merchant))); - Result getContractResult = await this.TransactionProcessorManager.GetContract(TestData.EstateId, TestData.ContractId, CancellationToken.None); + Result getContractResult = await this.TransactionProcessorManager.GetContract(TestData.EstateId, TestData.ContractId, TestContext.Current.CancellationToken); getContractResult.IsSuccess.ShouldBeTrue(); Contract contractModel = getContractResult.Data; @@ -130,7 +130,7 @@ public async Task TransactionProcessorManager_GetContract_ContractNotCreated_Err { this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); - Result getContractResult = await this.TransactionProcessorManager.GetContract(TestData.EstateId, TestData.ContractId, CancellationToken.None); + Result getContractResult = await this.TransactionProcessorManager.GetContract(TestData.EstateId, TestData.ContractId, TestContext.Current.CancellationToken); getContractResult.IsFailed.ShouldBeTrue(); } @@ -139,7 +139,7 @@ public async Task TransactionProcessorManager_GetContract_GetLatestFails_ErrorIs { this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result getContractResult = await this.TransactionProcessorManager.GetContract(TestData.EstateId, TestData.ContractId, CancellationToken.None); + Result getContractResult = await this.TransactionProcessorManager.GetContract(TestData.EstateId, TestData.ContractId, TestContext.Current.CancellationToken); getContractResult.IsFailed.ShouldBeTrue(); } @@ -148,7 +148,7 @@ public async Task TransactionProcessorManager_GetContracts_ContractAreReturned() { this.TransactionProcessorReadModelRepository.Setup(e => e.GetContracts(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new List() { TestData.ContractModelWithProductsAndTransactionFees })); - Result> getContractsResult = await this.TransactionProcessorManager.GetContracts(TestData.EstateId, CancellationToken.None); + Result> getContractsResult = await this.TransactionProcessorManager.GetContracts(TestData.EstateId, TestContext.Current.CancellationToken); getContractsResult.IsSuccess.ShouldBeTrue(); List contractModelList = getContractsResult.Data; contractModelList.ShouldNotBeNull(); @@ -160,7 +160,7 @@ public async Task TransactionProcessorManager_GetContracts_RepoCallFails_Contrac { this.TransactionProcessorReadModelRepository.Setup(e => e.GetContracts(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result> getContractsResult = await this.TransactionProcessorManager.GetContracts(TestData.EstateId, CancellationToken.None); + Result> getContractsResult = await this.TransactionProcessorManager.GetContracts(TestData.EstateId, TestContext.Current.CancellationToken); getContractsResult.IsFailed.ShouldBeTrue(); } @@ -169,7 +169,7 @@ public async Task TransactionProcessorManager_GetTransactionFeesForProduct_Trans { this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(CalculationType.Fixed, FeeType.Merchant))); - Result> getTransactionFeesForProductResult = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.VariableContractProductId, CancellationToken.None); + Result> getTransactionFeesForProductResult = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.VariableContractProductId, TestContext.Current.CancellationToken); getTransactionFeesForProductResult.IsSuccess.ShouldBeTrue(); List transactionFees = getTransactionFeesForProductResult.Data; transactionFees.ShouldNotBeNull(); @@ -182,7 +182,7 @@ public async Task TransactionProcessorManager_GetTransactionFeesForProduct_Contr { this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); - Result> result = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.FixedContractProductId, CancellationToken.None); + Result> result = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.FixedContractProductId, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -191,7 +191,7 @@ public async Task TransactionProcessorManager_GetTransactionFeesForProduct_Produ { this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); - Result> result = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.FixedContractProductId, CancellationToken.None); + Result> result = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.FixedContractProductId, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -200,7 +200,7 @@ public async Task TransactionProcessorManager_GetTransactionFeesForProduct_GetLa { this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result> result = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.FixedContractProductId, CancellationToken.None); + Result> result = await this.TransactionProcessorManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.FixedContractProductId, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } /* @@ -210,7 +210,7 @@ public async Task EstateManagementManager_GetFileDetails_FileDetailsAreReturned( { this.EstateManagementRepository.Setup(e => e.GetFileDetails(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.FileModel)); - var getFileDetailsResult = await this.EstateManagementManager.GetFileDetails(TestData.EstateId, TestData.FileId, CancellationToken.None); + var getFileDetailsResult = await this.EstateManagementManager.GetFileDetails(TestData.EstateId, TestData.FileId, TestContext.Current.CancellationToken); getFileDetailsResult.IsSuccess.ShouldBeTrue(); var fileDetails = getFileDetailsResult.Data; fileDetails.ShouldNotBeNull(); @@ -221,7 +221,7 @@ public async Task EstateManagementManager_GetFileDetails_RepoCallFailed_FileDeta { this.EstateManagementRepository.Setup(e => e.GetFileDetails(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - var getFileDetailsResult = await this.EstateManagementManager.GetFileDetails(TestData.EstateId, TestData.FileId, CancellationToken.None); + var getFileDetailsResult = await this.EstateManagementManager.GetFileDetails(TestData.EstateId, TestData.FileId, TestContext.Current.CancellationToken); getFileDetailsResult.IsFailed.ShouldBeTrue(); } */ @@ -230,7 +230,7 @@ public async Task TransactionProcessorManager_GetOperator_OperatorDetailsAreRetu { this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); - Result getOperatorResult = await this.TransactionProcessorManager.GetOperator(TestData.EstateId, TestData.OperatorId, CancellationToken.None); + Result getOperatorResult = await this.TransactionProcessorManager.GetOperator(TestData.EstateId, TestData.OperatorId, TestContext.Current.CancellationToken); getOperatorResult.IsSuccess.ShouldBeTrue(); Operator operatorDetails = getOperatorResult.Data; operatorDetails.ShouldNotBeNull(); @@ -241,7 +241,7 @@ public async Task TransactionProcessorManager_GetOperator_OperatorNotCreated_Exc { this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyOperatorAggregate())); - Result getOperatorResult = await this.TransactionProcessorManager.GetOperator(TestData.EstateId, TestData.OperatorId, CancellationToken.None); + Result getOperatorResult = await this.TransactionProcessorManager.GetOperator(TestData.EstateId, TestData.OperatorId, TestContext.Current.CancellationToken); getOperatorResult.IsFailed.ShouldBeTrue(); } @@ -250,7 +250,7 @@ public async Task TransactionProcessorManager_GetOperator_GetLatestFails_Excepti { this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result getOperatorResult = await this.TransactionProcessorManager.GetOperator(TestData.EstateId, TestData.OperatorId, CancellationToken.None); + Result getOperatorResult = await this.TransactionProcessorManager.GetOperator(TestData.EstateId, TestData.OperatorId, TestContext.Current.CancellationToken); getOperatorResult.IsFailed.ShouldBeTrue(); } @@ -261,7 +261,7 @@ public async Task TransactionProcessorManager_GetOperators_OperatorDetailsAreRet TestData.OperatorModel })); - Result> getOperatorsResult = await this.TransactionProcessorManager.GetOperators(TestData.EstateId, CancellationToken.None); + Result> getOperatorsResult = await this.TransactionProcessorManager.GetOperators(TestData.EstateId, TestContext.Current.CancellationToken); getOperatorsResult.IsSuccess.ShouldBeTrue(); List operators = getOperatorsResult.Data; operators.ShouldNotBeNull(); @@ -274,7 +274,7 @@ public async Task TransactionProcessorManager_GetOperators_EmptyList_ExceptionTh { this.TransactionProcessorReadModelRepository.Setup(e => e.GetOperators(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new List())); - Result> getOperatorsResult = await this.TransactionProcessorManager.GetOperators(TestData.EstateId, CancellationToken.None); + Result> getOperatorsResult = await this.TransactionProcessorManager.GetOperators(TestData.EstateId, TestContext.Current.CancellationToken); getOperatorsResult.IsSuccess.ShouldBeTrue(); } @@ -283,7 +283,7 @@ public async Task TransactionProcessorManager_GetOperators_RepoCallFails_Excepti { this.TransactionProcessorReadModelRepository.Setup(e => e.GetOperators(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result> getOperatorsResult = await this.TransactionProcessorManager.GetOperators(TestData.EstateId, CancellationToken.None); + Result> getOperatorsResult = await this.TransactionProcessorManager.GetOperators(TestData.EstateId, TestContext.Current.CancellationToken); getOperatorsResult.IsFailed.ShouldBeTrue(); } @@ -291,14 +291,14 @@ public async Task TransactionProcessorManager_GetOperators_RepoCallFails_Excepti public async Task TransactionProcessorManager_GetMerchant_MerchantIsReturned() { this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate))); - this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), CancellationToken.None)).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); + this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), TestContext.Current.CancellationToken)).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); this.TransactionProcessorReadModelRepository .Setup(r => r.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.MerchantModelWithAddressesContactsDevicesAndOperatorsAndContracts())); Merchant expectedModel = TestData.MerchantModelWithAddressesContactsDevicesAndOperatorsAndContracts(); - Result getMerchantResult = await this.TransactionProcessorManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + Result getMerchantResult = await this.TransactionProcessorManager.GetMerchant(TestData.EstateId, TestData.MerchantId, TestContext.Current.CancellationToken); getMerchantResult.IsSuccess.ShouldBeTrue(); Merchant merchantModel = getMerchantResult.Data; @@ -345,7 +345,7 @@ public async Task TransactionProcessorManager_GetMerchant_MerchantNotCreated_Err { this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - Result result = await this.TransactionProcessorManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + Result result = await this.TransactionProcessorManager.GetMerchant(TestData.EstateId, TestData.MerchantId, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -354,7 +354,7 @@ public async Task TransactionProcessorManager_GetMerchant_GetLatestFails_ErrorTh { this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result result = await this.TransactionProcessorManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + Result result = await this.TransactionProcessorManager.GetMerchant(TestData.EstateId, TestData.MerchantId, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -368,7 +368,7 @@ public async Task TransactionProcessorManager_GetMerchantSchedule_MerchantSchedu .Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(merchantScheduleAggregate)); - Result result = await this.TransactionProcessorManager.GetMerchantSchedule(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, CancellationToken.None); + Result result = await this.TransactionProcessorManager.GetMerchantSchedule(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.Year.ShouldBe(TestData.MerchantScheduleYear); @@ -384,7 +384,7 @@ public async Task TransactionProcessorManager_GetMerchantSchedule_MerchantSchedu .Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantScheduleAggregate())); - Result result = await this.TransactionProcessorManager.GetMerchantSchedule(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, CancellationToken.None); + Result result = await this.TransactionProcessorManager.GetMerchantSchedule(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -397,7 +397,7 @@ public async Task TransactionProcessorManager_GetMerchantScheduleFromReadModel_M .Setup(m => m.GetMerchantSchedule(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(expectedSchedule)); - Result result = await this.TransactionProcessorManager.GetMerchantScheduleFromReadModel(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, CancellationToken.None); + Result result = await this.TransactionProcessorManager.GetMerchantScheduleFromReadModel(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.Year.ShouldBe(TestData.MerchantScheduleYear); @@ -413,7 +413,7 @@ public async Task TransactionProcessorManager_GetMerchantScheduleFromReadModel_M .Setup(m => m.GetMerchantSchedule(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.TransactionProcessorManager.GetMerchantScheduleFromReadModel(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, CancellationToken.None); + Result result = await this.TransactionProcessorManager.GetMerchantScheduleFromReadModel(TestData.EstateId, TestData.MerchantId, TestData.MerchantScheduleYear, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -423,7 +423,7 @@ public async Task TransactionProcessorManager_GetMerchantContracts_MerchantContr { this.TransactionProcessorReadModelRepository.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantContracts)); - Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, TestContext.Current.CancellationToken); getMerchantContractsResult.IsSuccess.ShouldBeTrue(); List merchantContracts = getMerchantContractsResult.Data; merchantContracts.ShouldNotBeNull(); @@ -436,7 +436,7 @@ public async Task TransactionProcessorManager_GetMerchantContracts_EmptyListRetu { this.TransactionProcessorReadModelRepository.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantContractsEmptyList)); - Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, TestContext.Current.CancellationToken); getMerchantContractsResult.IsFailed.ShouldBeTrue(); } @@ -445,7 +445,7 @@ public async Task TransactionProcessorManager_GetMerchantContracts_RepoCallFaile { this.TransactionProcessorReadModelRepository.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, TestContext.Current.CancellationToken); getMerchantContractsResult.IsFailed.ShouldBeTrue(); } @@ -456,7 +456,7 @@ public async Task TransactionProcessorManager_GetMerchantContracts_RepositoryThr .Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + Result> getMerchantContractsResult = await this.TransactionProcessorManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, TestContext.Current.CancellationToken); getMerchantContractsResult.IsFailed.ShouldBeTrue(); getMerchantContractsResult.Message.ShouldBe("Test exception"); @@ -471,7 +471,7 @@ public async Task TransactionProcessorManager_GetMerchants_MerchantListIsReturne .MerchantModelWithAddressesContactsDevicesAndOperatorsAndContracts() })); - Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, CancellationToken.None); + Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, TestContext.Current.CancellationToken); getMerchantsResult.IsSuccess.ShouldBeTrue(); List merchantList = getMerchantsResult.Data; @@ -486,7 +486,7 @@ public async Task TransactionProcessorManager_GetMerchants_NullMerchants_Excepti List merchants = null; this.TransactionProcessorReadModelRepository.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(merchants)); - Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, CancellationToken.None); + Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, TestContext.Current.CancellationToken); getMerchantsResult.IsFailed.ShouldBeTrue(); } @@ -496,7 +496,7 @@ public async Task TransactionProcessorManager_GetMerchants_EmptyMerchants_Except List merchants = new List(); this.TransactionProcessorReadModelRepository.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(merchants)); - Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, CancellationToken.None); + Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, TestContext.Current.CancellationToken); getMerchantsResult.IsFailed.ShouldBeTrue(); } @@ -506,8 +506,9 @@ public async Task TransactionProcessorManager_GetMerchants_RepoCallFails_Excepti List merchants = new List(); this.TransactionProcessorReadModelRepository.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, CancellationToken.None); + Result> getMerchantsResult = await this.TransactionProcessorManager.GetMerchants(TestData.EstateId, TestContext.Current.CancellationToken); getMerchantsResult.IsFailed.ShouldBeTrue(); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs b/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs index 657ba13a..2eaa9898 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Moq; using Shared.DomainDrivenDesign.EventSourcing; @@ -65,12 +65,12 @@ await this.Context.VoucherProjectionStates.AddAsync(new VoucherProjectionState VoucherCode = TestData.VoucherCode, Barcode = TestData.Barcode, Timestamp = b - }); - await this.Context.SaveChangesAsync(CancellationToken.None); + }, TestContext.Current.CancellationToken); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); this.AggregateService.Setup(v => v.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetVoucherAggregateWithRecipientMobile())); - Result result = await this.VoucherManagementManager.GetVoucherByCode(TestData.EstateId, TestData.VoucherCode, CancellationToken.None); + Result result = await this.VoucherManagementManager.GetVoucherByCode(TestData.EstateId, TestData.VoucherCode, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); Models.Voucher voucher = result.Data; voucher.ShouldNotBeNull(); @@ -84,7 +84,7 @@ public async Task VoucherManagementManager_GetVoucherByCode_VoucherNotFound_Erro Should.Throw(async () => { - await this.VoucherManagementManager.GetVoucherByCode(TestData.EstateId, TestData.VoucherCode, CancellationToken.None); + await this.VoucherManagementManager.GetVoucherByCode(TestData.EstateId, TestData.VoucherCode, TestContext.Current.CancellationToken); }); } @@ -100,12 +100,12 @@ await this.Context.VoucherProjectionStates.AddAsync(new VoucherProjectionState VoucherCode = TestData.VoucherCode, Barcode = TestData.Barcode, Timestamp = b - }); - await this.Context.SaveChangesAsync(CancellationToken.None); + }, TestContext.Current.CancellationToken); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); this.AggregateService.Setup(v => v.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetVoucherAggregateWithRecipientMobile())); - var result = await VoucherManagementManager.GetVoucherByTransactionId(TestData.EstateId, TestData.TransactionId, CancellationToken.None); + var result = await VoucherManagementManager.GetVoucherByTransactionId(TestData.EstateId, TestData.TransactionId, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); Models.Voucher voucher = result.Data; voucher.ShouldNotBeNull(); @@ -118,8 +118,9 @@ public async Task VoucherManagementManager_GetVoucherByTransactionId_VoucherNotF Should.Throw(async () => { - await this.VoucherManagementManager.GetVoucherByTransactionId(TestData.EstateId, TestData.TransactionId, CancellationToken.None); + await this.VoucherManagementManager.GetVoucherByTransactionId(TestData.EstateId, TestData.TransactionId, TestContext.Current.CancellationToken); }); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs b/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs index 18e5e148..180d0af9 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs @@ -134,7 +134,7 @@ public async Task Mediator_Send_RequestHandled() { try { - await mediator.Send(baseRequest); + await mediator.Send(baseRequest, TestContext.Current.CancellationToken); } catch (Exception ex) { diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/AgencyBankingProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/AgencyBankingProxyTests.cs index e94466cd..53b46d24 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/AgencyBankingProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/AgencyBankingProxyTests.cs @@ -35,7 +35,7 @@ public async Task AgencyBankingProxy_ProcessLogonMessage_ReturnsSuccessfulResult AgencyBankingConfiguration configuration = CreateConfiguration(); IOperatorProxy proxy = new AgencyBankingProxy(httpClient, configuration); - var result = await proxy.ProcessLogonMessage(CancellationToken.None); + var result = await proxy.ProcessLogonMessage(TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldBeNull(); @@ -59,7 +59,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_MissingMessageType_Retur TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -84,7 +84,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_MissingAccountNumber_Ret TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -110,7 +110,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_UnsupportedMessageType_R TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -142,7 +142,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_BalanceEnquiryFailure_Re TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -176,7 +176,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_BalanceEnquiryTimeout_Re TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -209,7 +209,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_BalanceEnquirySuccess_Re TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -221,7 +221,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_BalanceEnquirySuccess_Re capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/balance-enquiry")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -253,7 +253,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_DepositFailure_ReturnsIn TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -263,7 +263,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_DepositFailure_ReturnsIn capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/deposit")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -290,7 +290,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_DepositMissingAmount_Ret TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -318,7 +318,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_DepositInvalidAmount_Ret TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -351,7 +351,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_DepositSuccess_ReturnsMa TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -364,7 +364,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_DepositSuccess_ReturnsMa capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/deposit")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -398,7 +398,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalFailure_Return TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -408,7 +408,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalFailure_Return capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/withdrawal")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -435,7 +435,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalMissingAmount_ TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -463,7 +463,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalInvalidAmount_ TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -496,7 +496,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalSuccess_Return TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -509,7 +509,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalSuccess_Return capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/withdrawal")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -543,7 +543,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalSuccess_WithMi TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -556,7 +556,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_WithdrawalSuccess_WithMi capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/withdrawal")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -589,7 +589,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_MiniStatementFailure_Ret TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -599,7 +599,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_MiniStatementFailure_Ret capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/mini-statement")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -648,7 +648,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_MiniStatementSuccess_Ret TestData.TransactionDateTime, TestData.TransactionReference, metadata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -674,7 +674,7 @@ public async Task AgencyBankingProxy_ProcessSaleMessage_MiniStatementSuccess_Ret capturedRequest.Method.ShouldBe(HttpMethod.Post); capturedRequest.RequestUri.ShouldBe(new Uri("http://localhost/transactions/mini-statement")); - String requestBody = await capturedRequest.Content.ReadAsStringAsync(); + String requestBody = await capturedRequest.Content.ReadAsStringAsync(TestContext.Current.CancellationToken); using JsonDocument requestJson = JsonDocument.Parse(requestBody); requestJson.RootElement.GetProperty("agentId").GetString().ShouldBe(TestData.Merchant.MerchantId.ToString()); requestJson.RootElement.GetProperty("accountNumber").GetString().ShouldBe("123456789"); @@ -701,3 +701,4 @@ private static HttpClient SetupMockHttpClient(HttpResponseMessage responseMessag } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs index de8c3a26..ad6917ae 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs @@ -1,4 +1,4 @@ -using SimpleResults; +using SimpleResults; using System; using System.Threading.Tasks; @@ -47,7 +47,7 @@ public async Task PataPawaPostPayProxy_ProcessLogonMessage_SuccessfulResponse_Me PataPawaPostPayService.Setup(s => s.getLoginRequestAsync(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.PataPawaPostPaidSuccessfulLoginResponse); - var logonResponseResult = await PataPawaPostPayProxy.ProcessLogonMessage(CancellationToken.None); + var logonResponseResult = await PataPawaPostPayProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); logonResponseResult.IsSuccess.ShouldBeTrue(); BusinessLogic.OperatorInterfaces.OperatorResponse logonResponse = logonResponseResult.Data; logonResponse.ShouldNotBeNull(); @@ -68,7 +68,7 @@ public async Task PataPawaPostPayProxy_ProcessLogonMessage_LogonCached_Successfu this.MemoryCache.Set("PataPawaPostPayLogon", operatorResponse, new MemoryCacheEntryOptions()); - var result = await PataPawaPostPayProxy.ProcessLogonMessage(CancellationToken.None); + var result = await PataPawaPostPayProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.TransactionId.ShouldBe(operatorResponse.TransactionId); @@ -79,7 +79,7 @@ public async Task PataPawaPostPayProxy_ProcessLogonMessage_FailedResponse_Messag PataPawaPostPayService.Setup(s => s.getLoginRequestAsync(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.PataPawaPostPaidFailedLoginResponse); - var result = await this.PataPawaPostPayProxy.ProcessLogonMessage(CancellationToken.None); + var result = await this.PataPawaPostPayProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -98,7 +98,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_VerifyAccount_Successf TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaVerifyAccount(), - CancellationToken.None); + TestContext.Current.CancellationToken); processSaleMessageResult.IsSuccess.ShouldBeTrue(); BusinessLogic.OperatorInterfaces.OperatorResponse saleResponse = processSaleMessageResult.Data; @@ -127,7 +127,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_VerifyAccount_FailedLo TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaVerifyAccount(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("PataPawaPostPaidAPIKey"); @@ -143,7 +143,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_VerifyAccount_MissingM TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaVerifyAccount_NoMessageType(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("PataPawaPostPaidMessageType"); @@ -160,7 +160,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_VerifyAccount_MissingC TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaVerifyAccount_NoCustomerAccountNumber(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("CustomerAccountNumber"); @@ -177,7 +177,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_VerifyAccount_InvalidM TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaVerifyAccount(pataPawaPostPaidMessageType:"Unknown"), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); @@ -198,7 +198,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_VerifyAccount_RequestF TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaVerifyAccount(customerAccountNumber: TestData.PataPawaPostPaidAccountNumber), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.NotFound); result.Message.Contains($"Error verifying account number {TestData.PataPawaPostPaidAccountNumber}"); @@ -217,7 +217,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_VerifyAccount_Timeout_ TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaVerifyAccount(customerAccountNumber: TestData.PataPawaPostPaidAccountNumber), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -239,7 +239,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_Timeout_Er TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill(customerAccountNumber: TestData.PataPawaPostPaidAccountNumber), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -262,7 +262,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_Successful TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill(), - CancellationToken.None); + TestContext.Current.CancellationToken); processSaleMessageResult.IsSuccess.ShouldBeTrue(); BusinessLogic.OperatorInterfaces.OperatorResponse saleResponse = processSaleMessageResult.Data; saleResponse.ShouldNotBeNull(); @@ -279,7 +279,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_FailedLogo var result = await this.PataPawaPostPayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -296,7 +296,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_MissingMes TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill_NoMessageType(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("PataPawaPostPaidAPIKey"); @@ -313,7 +313,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_MissingCus TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill_NoCustomerAccountNumber(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -331,7 +331,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_MissingMob TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill_NoMobileNumber(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("MobileNumber"); @@ -348,7 +348,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_MissingCus TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill_NoCustomerName(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("CustomerName"); @@ -365,7 +365,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_MissingAmo TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill_NoAmount(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("Amount"); @@ -382,7 +382,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_InvalidAmo TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill(pataPawaPostPaidAmount:"A1"), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("Amount"); @@ -399,7 +399,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_InvalidMes TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill(pataPawaPostPaidMessageType: "Unknown"), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); result.Message.Contains("PataPawaPostPaidMessageType"); @@ -419,7 +419,7 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_RequestFai TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForPataPawaProcessBill(customerAccountNumber:TestData.PataPawaPostPaidAccountNumber), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -427,3 +427,4 @@ public async Task PataPawaPostPayProxy_ProcessSaleMessage_ProcessBill_RequestFai } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs index ca43ec2d..caa78439 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Caching.Memory; using RichardSzalay.MockHttp; using Shared.Logger; using Shared.Serialisation; @@ -45,7 +45,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_MessageProcessed() { this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(logonResponse)); - var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None); + var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe("0000"); result.Data.IsSuccessful.ShouldBeTrue(); @@ -58,7 +58,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_CachedResponse_Message this.MemoryCache.Set("PataPawaPrePayLogon", operatorResponse, new MemoryCacheEntryOptions()); LogonResponse logonResponse = new LogonResponse { Balance = "0", Key = "Key", Msg = "Success", Status = 0 }; - var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None); + var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.TransactionId.ShouldBe(operatorResponse.TransactionId); } @@ -70,7 +70,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_FailedLogon_MessagePro this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(logonResponse)); - var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None); + var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -81,7 +81,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_HttpCallFailed_Message this.MockHttpMessageHandler.When("http://localhost").Respond(req => new HttpResponseMessage(HttpStatusCode.BadRequest)); - var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None); + var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -108,7 +108,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterTransaction_Messag var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe("0000"); @@ -138,7 +138,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterTransaction_Failed var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -165,7 +165,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterTransaction_Timeou var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -201,7 +201,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_Message var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe("0000"); @@ -241,7 +241,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_FailedA var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -270,7 +270,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_Timeout var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -313,7 +313,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_Custome var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -353,7 +353,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_AmountI var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -391,7 +391,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_UnknownMessageType_Mess var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -420,7 +420,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_NoLogonResponse_Message var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -451,7 +451,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_APIKeyNullOrEmpty_Messa var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -482,7 +482,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MessageTypeNullOrEmpty_ var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); @@ -513,10 +513,11 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterNumberNullOrEmpty_ var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, - metaDataDictionary, CancellationToken.None); + metaDataDictionary, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs index 1cbc1bdb..0b95bc19 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs @@ -1,4 +1,4 @@ -using SimpleResults; +using SimpleResults; using System; using System.Collections.Generic; @@ -37,7 +37,7 @@ public async Task SafaricomPinlessProxy_ProcessLogonMessage_NullIsReturned() { HttpClient httpClient = SetupMockHttpClient(responseMessage); IOperatorProxy safaricomPinlessproxy = new SafaricomPinlessProxy(safaricomConfiguration, httpClient); - var processLogonMessageResult = await safaricomPinlessproxy.ProcessLogonMessage(CancellationToken.None); + var processLogonMessageResult = await safaricomPinlessproxy.ProcessLogonMessage(TestContext.Current.CancellationToken); processLogonMessageResult.IsSuccess.ShouldBeTrue(); OperatorResponse operatorResponse = processLogonMessageResult.Data; operatorResponse.ShouldBeNull(); @@ -64,7 +64,7 @@ public async Task SafaricomPinlessProxy_ProcessSaleMessage_TopupSuccessful_SaleM TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForMobileTopup(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); result.Data.IsSuccessful.ShouldBeTrue(); @@ -95,7 +95,7 @@ public async Task SafaricomPinlessProxy_ProcessSaleMessage_MetadataCasingTests_A TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForMobileTopup(amountName: amountFieldName), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -128,7 +128,7 @@ public async Task SafaricomPinlessProxy_ProcessSaleMessage_MetadataCasingTests_C TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForMobileTopup(customerAccountNumberName: customerAccountNumberFieldName), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -157,7 +157,7 @@ public async Task SafaricomPinlessProxy_ProcessSaleMessage_TopupFailed_SaleMessa TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForMobileTopup(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -182,7 +182,7 @@ public async Task SafaricomPinlessProxy_ProcessSaleMessage_FailedToSend_ErrorThr TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForMobileTopup(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -207,7 +207,7 @@ public async Task SafaricomPinlessProxy_ProcessSaleMessage_Timeout_ErrorThrown() TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForMobileTopup(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -246,7 +246,7 @@ public async Task SafaricomPinlessProxy_ProcessSaleMessage_InvalidData_ErrorThro TestData.TransactionDateTime, TestData.TransactionReference, additionalMetatdata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); } @@ -266,3 +266,4 @@ private HttpClient SetupMockHttpClient(HttpResponseMessage responseMessage) } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs index 41de6a82..119bd673 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs @@ -1,4 +1,4 @@ -using Shared.Logger; +using Shared.Logger; using SimpleResults; namespace TransactionProcessor.BusinessLogic.Tests.OperatorInterfaces @@ -31,7 +31,7 @@ public async Task VoucherManagementProxy_ProcessLogonMessage_NullReturned() { IOperatorProxy voucherManagementProxy = new VoucherManagementProxy(mediator.Object); - var processLogonMessageResult = await voucherManagementProxy.ProcessLogonMessage(CancellationToken.None); + var processLogonMessageResult = await voucherManagementProxy.ProcessLogonMessage(TestContext.Current.CancellationToken); processLogonMessageResult.IsSuccess.ShouldBeTrue(); OperatorResponse operatorResponse = processLogonMessageResult.Data; operatorResponse.ShouldBeNull(); @@ -49,7 +49,7 @@ public async Task VoucherManagementProxy_ProcessSaleMessage_VoucherIssueSuccessf TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForVoucher(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); var operatorResponse = result.Data; operatorResponse.ShouldNotBeNull(); @@ -73,7 +73,7 @@ public async Task VoucherManagementProxy_ProcessSaleMessage_VoucherIssueFailed_F TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForVoucher(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -92,7 +92,7 @@ public async Task VoucherManagementProxy_ProcessSaleMessage_VoucherIssueThrowsTi TestData.TransactionDateTime, TestData.TransactionReference, TestData.AdditionalTransactionMetaDataForVoucher(), - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Failure); @@ -119,7 +119,7 @@ public async Task VoucherManagementProxy_ProcessSaleMessage_InvalidData_Transact TestData.TransactionDateTime, TestData.TransactionReference, additionalMetatdata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); @@ -151,9 +151,10 @@ public async Task VoucherManagementProxy_ProcessSaleMessage_InvalidData_Recipien TestData.TransactionDateTime, TestData.TransactionReference, additionalMetatdata, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Status.ShouldBe(ResultStatus.Invalid); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs index 9fa899d8..148d7a0a 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs @@ -1,4 +1,4 @@ -using SimpleResults; +using SimpleResults; using System.Threading.Tasks; namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler; @@ -24,10 +24,10 @@ public FloatRequestHandlerTests() { public async Task FloatRequestHandler_CreateFloatForContractProductRequest_IsHandled(){ Mock floatDomainService = new Mock(); FloatRequestHandler handler = new FloatRequestHandler(floatDomainService.Object); - floatDomainService.Setup(f => f.CreateFloatForContractProduct(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); - var command = TestData.CreateFloatForContractProductCommand; + floatDomainService.Setup(f => f.CreateFloat(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); + var command = TestData.CreateFloatCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -41,8 +41,8 @@ public async Task FloatRequestHandler_RecordCreditPurchaseForFloatRequest_IsHand var command = TestData.RecordCreditPurchaseForFloatCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/MerchantRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/MerchantRequestHandlerTests.cs index 6cecdf90..7e50064d 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/MerchantRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/MerchantRequestHandlerTests.cs @@ -50,7 +50,7 @@ public async Task MerchantRequestHandler_GetMerchantQuery_ReturnsMerchantReporti MerchantQueries.GetMerchantQuery query = TestData.Queries.GetMerchantQuery; - var result = await handler.Handle(query, CancellationToken.None); + var result = await handler.Handle(query, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -58,3 +58,4 @@ public async Task MerchantRequestHandler_GetMerchantQuery_ReturnsMerchantReporti manager.Verify(m => m.GetMerchant(TestData.EstateId, TestData.MerchantId, It.IsAny()), Times.Once); } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs index da54b86a..759f5d75 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.Serialisation; @@ -33,7 +33,8 @@ public async Task SettlementRequestHandler_ProcessSettlementRequest_IsHandled() .Setup(s => s.ProcessSettlement(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); var command = TestData.Commands.ProcessSettlementCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs index 24536b87..a2181e45 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shared.Serialisation; using Shouldly; using SimpleResults; @@ -28,7 +28,7 @@ public async Task TransactionRequestHandler_ProcessLogonTransactionRequest_IsHan It.IsAny())).ReturnsAsync(Result.Success()); TransactionCommands.ProcessLogonTransactionCommand command = TestData.Commands.ProcessLogonTransactionCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -42,7 +42,7 @@ public async Task TransactionRequestHandler_ProcessSaleTransactionRequest_IsHand It.IsAny())).ReturnsAsync(Result.Success()); TransactionCommands.ProcessSaleTransactionCommand command = TestData.Commands.ProcessSaleTransactionCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -56,7 +56,7 @@ public async Task TransactionRequestHandler_ProcessReconciliationRequest_IsHandl It.IsAny())).ReturnsAsync(Result.Success()); TransactionCommands.ProcessReconciliationCommand command = TestData.Commands.ProcessReconciliationCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -71,8 +71,8 @@ public async Task TransactionRequestHandler_ResendTransactionReceiptRequest_IsHa It.IsAny())).ReturnsAsync(Result.Success()); TransactionCommands.ResendTransactionReceiptCommand command = TestData.Commands.ResendTransactionReceiptCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs index 4a101958..a5abdb99 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shouldly; using System; using System.Threading.Tasks; @@ -32,7 +32,7 @@ public async Task VoucherManagementRequestHandler_IssueVoucherRequest_IsHandled( VoucherManagementRequestHandler handler = new VoucherManagementRequestHandler(voucherDomainService.Object, voucherManagementManager.Object); var command = TestData.IssueVoucherCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -47,8 +47,9 @@ public async Task VoucherManagementRequestHandler_RedeemVoucherRequest_IsHandled VoucherManagementRequestHandler handler = new VoucherManagementRequestHandler(voucherDomainService.Object, voucherManagementManager.Object); var command = TestData.RedeemVoucherCommand; - var result = await handler.Handle(command, CancellationToken.None); + var result = await handler.Handle(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs index c0523daa..032903bb 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; using Moq; @@ -43,7 +43,7 @@ public async Task ContractDomainService_CreateContract_ContractIsCreated() .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -59,7 +59,7 @@ public async Task ContractDomainService_CreateContract_DuplicateContractNameForO .ReturnsAsync(queryResult); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -75,7 +75,7 @@ public async Task ContractDomainService_CreateContract_ContractAlreadyCreated_Re .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -88,7 +88,7 @@ public async Task ContractDomainService_CreateContract_EstateNotCreated_ResultFa .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -101,7 +101,7 @@ public async Task ContractDomainService_CreateContract_NoOperatorCreatedForEstat .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -115,7 +115,7 @@ public async Task ContractDomainService_CreateContract_OperatorNotFoundForEstate .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -130,7 +130,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_ProductA .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -144,7 +144,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_Contract .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -160,7 +160,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_Produ .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -174,7 +174,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_Contr .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -188,7 +188,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_Estat .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -202,7 +202,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_EstateNo .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -224,7 +224,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Tr ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType, feeType); - Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -244,7 +244,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Co ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType,feeType); - Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -265,7 +265,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Pr ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType, feeType); - Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -289,7 +289,7 @@ public async Task ContractDomainService_DisableTransactionFeeForProduct_Transact .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.DisableTransactionFeeForProductCommand command = TestData.Commands.DisableTransactionFeeForProductCommand; - Result result = await this.DomainService.DisableTransactionFeeForProduct(command, CancellationToken.None); + Result result = await this.DomainService.DisableTransactionFeeForProduct(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -300,7 +300,7 @@ public async Task ContractDomainService_DisableTransactionFeeForProduct_GetContr .ReturnsAsync(Result.Failure()); ContractCommands.DisableTransactionFeeForProductCommand command = TestData.Commands.DisableTransactionFeeForProductCommand; - Result result = await this.DomainService.DisableTransactionFeeForProduct(command, CancellationToken.None); + Result result = await this.DomainService.DisableTransactionFeeForProduct(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -311,7 +311,7 @@ public async Task ContractDomainService_DisableTransactionFeeForProduct_StateCha .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); ContractCommands.DisableTransactionFeeForProductCommand command = TestData.Commands.DisableTransactionFeeForProductCommand; - Result result = await this.DomainService.DisableTransactionFeeForProduct(command, CancellationToken.None); + Result result = await this.DomainService.DisableTransactionFeeForProduct(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -324,7 +324,7 @@ public async Task ContractDomainService_DisableTransactionFeeForProduct_SaveFail .ReturnsAsync(Result.Failure()); ContractCommands.DisableTransactionFeeForProductCommand command = TestData.Commands.DisableTransactionFeeForProductCommand; - Result result = await this.DomainService.DisableTransactionFeeForProduct(command, CancellationToken.None); + Result result = await this.DomainService.DisableTransactionFeeForProduct(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -336,7 +336,7 @@ public async Task ContractDomainService_DisableTransactionFeeForProduct_Exceptio this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); ContractCommands.DisableTransactionFeeForProductCommand command = TestData.Commands.DisableTransactionFeeForProductCommand; - Result result = await this.DomainService.DisableTransactionFeeForProduct(command, CancellationToken.None); + Result result = await this.DomainService.DisableTransactionFeeForProduct(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -347,7 +347,7 @@ public async Task ContractDomainService_CreateContract_GetEstateFailed_ResultIsF .ReturnsAsync(Result.Failure()); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -360,7 +360,7 @@ public async Task ContractDomainService_CreateContract_GetContractFailed_ResultI .ReturnsAsync(Result.Failure()); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -375,7 +375,7 @@ public async Task ContractDomainService_CreateContract_RunTransientQueryFailed_R .ReturnsAsync(Result.Failure()); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -396,7 +396,7 @@ public async Task ContractDomainService_CreateContract_StateChangeFailed_ResultI OperatorId = TestData.Commands.CreateContractCommand.RequestDTO.OperatorId } }; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -413,7 +413,7 @@ public async Task ContractDomainService_CreateContract_SaveFailed_ResultIsFailed .ReturnsAsync(Result.Failure()); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -429,7 +429,7 @@ public async Task ContractDomainService_CreateContract_ExceptionThrown_ResultIsF this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; - Result result = await this.DomainService.CreateContract(command, CancellationToken.None); + Result result = await this.DomainService.CreateContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -440,7 +440,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_GetContr .ReturnsAsync(Result.Failure()); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -451,7 +451,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_GetCo .ReturnsAsync(Result.Failure()); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -465,7 +465,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_StateCha ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; command = command with { ProductId = Guid.Empty }; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -478,7 +478,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_SaveFail .ReturnsAsync(Result.Failure()); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -491,7 +491,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_SaveF .ReturnsAsync(Result.Failure()); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; - Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -509,7 +509,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Ge ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType, feeType); - Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -529,7 +529,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Sa ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType, feeType); - Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -544,8 +544,9 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_St ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(DataTransferObjects.Responses.Contract.CalculationType.Fixed, DataTransferObjects.Responses.Contract.FeeType.Merchant); command = command with { TransactionFeeId = Guid.Empty }; - Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, CancellationToken.None); + Result result = await this.DomainService.AddTransactionFeeForProductToContract(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs index f371d9e6..072f5474 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using SecurityService.Client; using SecurityService.DataTransferObjects; using Shared.DomainDrivenDesign.EventSourcing; @@ -41,7 +41,7 @@ public async Task EstateDomainService_CreateEstate_EstateIsCreated() { .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(SimpleResults.Result.Success()); - Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -56,7 +56,7 @@ public async Task EstateDomainService_AddOperatorEstate_OperatorIsAdded() .ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.CreatedEstateAggregate())); this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())).ReturnsAsync(SimpleResults.Result.Success()); - Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, CancellationToken.None); + Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -65,7 +65,7 @@ public async Task EstateDomainService_RemoveOperatorFromEstate_OperatorIsRemoved { this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, CancellationToken.None); + Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -87,7 +87,7 @@ public async Task EstateDomainService_CreateEstateUser_EstateUserIsCreated() { } })); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -116,7 +116,7 @@ public async Task EstateDomainService_CreateEstateUser_EstateRoleOverrideIsUsedI } })); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); capturedRequest.ShouldNotBeNull(); @@ -147,7 +147,7 @@ public async Task EstateDomainService_CreateEstateUser_UserCreateFailed_ResultIs } })); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -166,7 +166,7 @@ public async Task EstateDomainService_CreateEstateUser_GetUsersFailed_ResultIsFa .Setup(s => s.GetUsers(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -187,7 +187,7 @@ public async Task EstateDomainService_CreateEstateUser_NullUserReturned_ResultIs null })); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -208,7 +208,7 @@ public async Task EstateDomainService_CreateEstateUser_GetEstateFailed_ResultIsF } })); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -231,7 +231,7 @@ public async Task EstateDomainService_CreateEstateUser_EstateNotCreated_ResultIs } })); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -254,7 +254,7 @@ public async Task EstateDomainService_CreateEstateUser_SaveFailed_ResultIsFailed } })); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -264,7 +264,7 @@ public async Task EstateDomainService_CreateEstate_GetEstateFailed_ResultIsFaile this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -277,7 +277,7 @@ public async Task EstateDomainService_CreateEstate_EstateNameEmpty_ResultIsFaile EstateCommands.CreateEstateCommand emptyNameCommand = new EstateCommands.CreateEstateCommand( new CreateEstateRequest { EstateId = TestData.EstateId, EstateName = String.Empty }); - Result result = await this.DomainService.CreateEstate(emptyNameCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstate(emptyNameCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -290,7 +290,7 @@ public async Task EstateDomainService_CreateEstate_SaveFailed_ResultIsFailed() .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure); - Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -302,7 +302,7 @@ public async Task EstateDomainService_AddOperatorToEstate_GetOperatorFailed_Resu this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.CreatedEstateAggregate())); - Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, CancellationToken.None); + Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -314,7 +314,7 @@ public async Task EstateDomainService_AddOperatorToEstate_GetEstateFailed_Result this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, CancellationToken.None); + Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -326,7 +326,7 @@ public async Task EstateDomainService_AddOperatorToEstate_EstateNotCreated_Resul this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.EmptyEstateAggregate)); - Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, CancellationToken.None); + Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -340,7 +340,7 @@ public async Task EstateDomainService_AddOperatorToEstate_SaveFailed_ResultIsFai this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure); - Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, CancellationToken.None); + Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -350,7 +350,7 @@ public async Task EstateDomainService_RemoveOperatorFromEstate_GetEstateFailed_R this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, CancellationToken.None); + Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -360,7 +360,7 @@ public async Task EstateDomainService_RemoveOperatorFromEstate_EstateNotCreated_ this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyEstateAggregate)); - Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, CancellationToken.None); + Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -370,7 +370,7 @@ public async Task EstateDomainService_RemoveOperatorFromEstate_OperatorNotAdded_ this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); - Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, CancellationToken.None); + Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -382,7 +382,7 @@ public async Task EstateDomainService_RemoveOperatorFromEstate_SaveFailed_Result this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure); - Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, CancellationToken.None); + Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -392,7 +392,7 @@ public async Task EstateDomainService_CreateEstate_ExceptionThrown_ResultIsFaile this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception()); - Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -402,7 +402,7 @@ public async Task EstateDomainService_AddOperatorToEstate_ExceptionThrown_Result this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception()); - Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, CancellationToken.None); + Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -413,7 +413,7 @@ public async Task EstateDomainService_CreateEstateUser_ExceptionThrown_ResultIsF .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception()); - Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -423,8 +423,9 @@ public async Task EstateDomainService_RemoveOperatorFromEstate_ExceptionThrown_R this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception()); - Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, CancellationToken.None); + Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs index f2649cde..5fba3a5a 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs @@ -1,4 +1,4 @@ -using SimpleResults; +using SimpleResults; using System; using System.Threading.Tasks; using TransactionProcessor.BusinessLogic.Requests; @@ -16,6 +16,7 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using System.Text.Json; using System.Threading; using Testing; + using TransactionProcessor.BusinessLogic.Common; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Services; using Xunit; @@ -41,14 +42,12 @@ public FloatDomainServiceTests(){ public async Task FloatDomainService_CreateFloatForContractProduct_FloatCreated(){ 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.GetLatest(TestData.OperatorId, It.IsAny())).ReturnsAsync(Result.Success(FloatAggregate.Create(TestData.OperatorId))); this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); - FloatCommands.CreateFloatForContractProductCommand command = new FloatCommands.CreateFloatForContractProductCommand(TestData.EstateId, TestData.ContractId, - TestData.ProductId, TestData.FloatCreatedDateTime); - Result result = await this.FloatDomainService.CreateFloatForContractProduct(command, CancellationToken.None); + FloatCommands.CreateFloatCommand command = new FloatCommands.CreateFloatCommand(TestData.EstateId, TestData.OperatorId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloat(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -56,47 +55,42 @@ public async Task FloatDomainService_CreateFloatForContractProduct_FloatCreated( public async Task FloatDomainService_CreateFloatForContractProduct_InvalidEstate_ErrorThrown() { this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.NotFound()); - FloatCommands.CreateFloatForContractProductCommand command = new FloatCommands.CreateFloatForContractProductCommand(TestData.EstateId, TestData.ContractId, - TestData.ProductId, TestData.FloatCreatedDateTime); - Result result = await this.FloatDomainService.CreateFloatForContractProduct(command, CancellationToken.None); + FloatCommands.CreateFloatCommand command = new FloatCommands.CreateFloatCommand(TestData.EstateId, TestData.OperatorId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloat(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } [Fact] - public async Task FloatDomainService_CreateFloatForContractProduct_InvalidContract_ErrorThrown() + public async Task FloatDomainService_CreateFloatForContractProduct_InvalidOperator_ErrorThrown() { 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.NotFound()); - FloatCommands.CreateFloatForContractProductCommand command = new FloatCommands.CreateFloatForContractProductCommand(TestData.EstateId, TestData.ContractId, - TestData.ProductId, TestData.FloatCreatedDateTime); - Result result = await this.FloatDomainService.CreateFloatForContractProduct(command, CancellationToken.None); + FloatCommands.CreateFloatCommand command = new FloatCommands.CreateFloatCommand(TestData.EstateId, TestData.OperatorId2, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloat(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } [Fact] - public async Task FloatDomainService_CreateFloatForContractProduct_InvalidContractProduct_ErrorThrown() + public async Task FloatDomainService_CreateFloatForContractProduct_DeletedOperator_ErrorThrown() { - 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.CreatedContractAggregate())); + this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperatorDeleted())); - FloatCommands.CreateFloatForContractProductCommand command = new FloatCommands.CreateFloatForContractProductCommand(TestData.EstateId, TestData.ContractId, - TestData.ProductId, TestData.FloatCreatedDateTime); - Result result = await this.FloatDomainService.CreateFloatForContractProduct(command, CancellationToken.None); + FloatCommands.CreateFloatCommand command = new FloatCommands.CreateFloatCommand(TestData.EstateId, TestData.OperatorId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloat(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } [Fact] public async Task FloatDomainService_RecordCreditPurchase_PurchaseRecorded(){ FloatAggregate floatAggregate = FloatAggregate.Create(TestData.FloatAggregateId); - floatAggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + floatAggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(floatAggregate)); this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); 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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -104,14 +98,14 @@ public async Task FloatDomainService_RecordCreditPurchase_PurchaseRecorded(){ public async Task FloatDomainService_RecordCreditPurchase_SaveFailed() { FloatAggregate floatAggregate = FloatAggregate.Create(TestData.FloatAggregateId); - floatAggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + floatAggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(floatAggregate)); this.AggregateService.Setup(f => f.Save(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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -119,14 +113,14 @@ public async Task FloatDomainService_RecordCreditPurchase_SaveFailed() public async Task FloatDomainService_RecordCreditPurchase_ExceptionThrown() { FloatAggregate floatAggregate = FloatAggregate.Create(TestData.FloatAggregateId); - floatAggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + floatAggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); this.AggregateService.Setup(f => f.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(floatAggregate)); this.AggregateService.Setup(f => f.Save(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); 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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -139,7 +133,7 @@ public async Task FloatDomainService_RecordCreditPurchase_FloatActivity_Purchase 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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -152,7 +146,7 @@ public async Task FloatDomainService_RecordCreditPurchase_FloatActivity_SaveFail 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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -165,7 +159,7 @@ public async Task FloatDomainService_RecordCreditPurchase_FloatActivity_Exceptio 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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -173,12 +167,10 @@ public async Task FloatDomainService_RecordCreditPurchase_FloatActivity_Exceptio 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()); + this.AggregateService.Setup(f => f.GetLatest(TestData.OperatorId, 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); + FloatCommands.CreateFloatCommand command = new FloatCommands.CreateFloatCommand(TestData.EstateId, TestData.OperatorId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloat(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -186,13 +178,11 @@ public async Task FloatDomainService_CreateFloatForContractProduct_GetFloatFaile 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.GetLatest(TestData.OperatorId, It.IsAny())).ReturnsAsync(Result.Success(FloatAggregate.Create(TestData.OperatorId))); 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); + FloatCommands.CreateFloatCommand command = new FloatCommands.CreateFloatCommand(TestData.EstateId, TestData.OperatorId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloat(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -200,13 +190,11 @@ public async Task FloatDomainService_CreateFloatForContractProduct_SaveFailed() 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.GetLatest(TestData.OperatorId, It.IsAny())).ReturnsAsync(Result.Success(FloatAggregate.Create(TestData.OperatorId))); 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); + FloatCommands.CreateFloatCommand command = new FloatCommands.CreateFloatCommand(TestData.EstateId, TestData.OperatorId, TestData.FloatCreatedDateTime); + Result result = await this.FloatDomainService.CreateFloat(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -218,7 +206,7 @@ public async Task FloatDomainService_RecordCreditPurchase_GetFloatFailed() 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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -229,20 +217,21 @@ public async Task FloatDomainService_RecordCreditPurchase_FloatActivity_GetFloat 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 result = await this.FloatDomainService.RecordCreditPurchase(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } [Fact] public async Task FloatDomainService_RecordTransaction_TransactionRecorded() { - FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(TestData.FloatAggregateId); + Guid floatActivityAggregateId = IdGenerationService.GenerateFloatActivityAggregateId(TestData.EstateId, TestData.OperatorId, TestData.TransactionDateTime.Date); + FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(floatActivityAggregateId); 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.GetLatest(floatActivityAggregateId, 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 result = await this.FloatDomainService.RecordTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -252,7 +241,7 @@ 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 result = await this.FloatDomainService.RecordTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -263,34 +252,37 @@ public async Task FloatDomainService_RecordTransaction_GetFloatActivityFailed() 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 result = await this.FloatDomainService.RecordTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } [Fact] public async Task FloatDomainService_RecordTransaction_SaveFailed() { - FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(TestData.FloatAggregateId); + Guid floatActivityAggregateId = IdGenerationService.GenerateFloatActivityAggregateId(TestData.EstateId, TestData.OperatorId, TestData.TransactionDateTime.Date); + FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(floatActivityAggregateId); 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.GetLatest(floatActivityAggregateId, 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 result = await this.FloatDomainService.RecordTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } [Fact] public async Task FloatDomainService_RecordTransaction_ExceptionThrown() { - FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(TestData.FloatAggregateId); + Guid floatActivityAggregateId = IdGenerationService.GenerateFloatActivityAggregateId(TestData.EstateId, TestData.OperatorId, TestData.TransactionDateTime.Date); + FloatActivityAggregate floatActivityAggregate = FloatActivityAggregate.Create(floatActivityAggregateId); 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.GetLatest(floatActivityAggregateId, 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 result = await this.FloatDomainService.RecordTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs index 65e981ee..9f430315 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using Moq; using SecurityService.Client; using SecurityService.DataTransferObjects; @@ -73,7 +73,7 @@ public async Task MerchantDomainService_CreateMerchant_MerchantIsCreated( command.RequestDto.SettlementSchedule = settlementSchedule; - Result result = await this.DomainService.CreateMerchant(command, CancellationToken.None); + Result result = await this.DomainService.CreateMerchant(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -91,7 +91,7 @@ public async Task MerchantDomainService_CreateMerchant_MerchantIdNotSet_Merchant MerchantCommands.CreateMerchantCommand command = TestData.Commands.CreateMerchantCommand; command.RequestDto.MerchantId = null; - Result result = await this.DomainService.CreateMerchant(command, CancellationToken.None); + Result result = await this.DomainService.CreateMerchant(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -107,9 +107,9 @@ public async Task MerchantDomainService_CreateMerchant_AlreadyCreated_MerchantIs .ReturnsAsync(TestData.Aggregates.CreatedEstateAggregate()); Result result = - await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, CancellationToken.None); + await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, CancellationToken.None); + result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -124,7 +124,7 @@ public async Task MerchantDomainService_CreateMerchant_EstateNotFound_ErrorThrow .ReturnsAsync(TestData.Aggregates.EmptyEstateAggregate); Result result = - await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, CancellationToken.None); + await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -143,7 +143,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_OperatorAssigne Result result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -159,7 +159,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_MerchantNotCrea .ReturnsAsync(TestData.Aggregates.EstateAggregateWithOperator()); Result result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -175,7 +175,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_EstateNotCreate .ReturnsAsync(TestData.Aggregates.EmptyEstateAggregate); var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -191,7 +191,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_OperatorNotFoun .ReturnsAsync(TestData.Aggregates.CreatedEstateAggregate()); var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -220,7 +220,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_OperatorRequire TerminalNumber = TestData.TerminalNumber }); - var result = await this.DomainService.AssignOperatorToMerchant(command, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -249,7 +249,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_OperatorRequire TerminalNumber = terminalNumber }); - var result = await this.DomainService.AssignOperatorToMerchant(command, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -275,7 +275,7 @@ public async Task MerchantDomainService_CreateMerchantUser_MerchantUserIsCreated } })); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -294,7 +294,7 @@ public async Task MerchantDomainService_CreateMerchantUser_EstateNotCreated_Erro .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -313,7 +313,7 @@ public async Task MerchantDomainService_CreateMerchantUser_MerchantNotCreated_Er .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -332,7 +332,7 @@ public async Task MerchantDomainService_CreateMerchantUser_ErrorCreatingUser_Err .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -355,7 +355,7 @@ public async Task MerchantDomainService_CreateMerchantUser_ErrorGettingUsers_Err .Setup(s => s.GetUsers(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -380,7 +380,7 @@ public async Task MerchantDomainService_CreateMerchantUser_UserInListIsNull_Erro null })); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -395,7 +395,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_MerchantDeviceIsAdde .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -410,7 +410,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_EstateNotCreated_Err .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -425,7 +425,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_MerchantNotCreated_E .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -445,7 +445,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_DepositIsMade() .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success()); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -465,7 +465,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_DuplicateDeposit_Res .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success()); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -482,7 +482,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_GetDepositListFailed .Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -502,7 +502,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_DepositListSaveFaile .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -514,7 +514,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_EstateNotCreated_Err this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantAggregate())); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -526,7 +526,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_MerchantNotCreated_E this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -545,7 +545,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_NoDepositsYet_Deposi .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success()); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -560,7 +560,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_MerchantDeviceSwapped .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -575,7 +575,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_MerchantNotCreated_Er .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -590,7 +590,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_EstateNotCreated_Erro .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - Result result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None); + Result result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -607,7 +607,7 @@ public async Task MerchantDomainService_UpdateMerchantOpeningHours_Success() .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.UpdateMerchantOpeningHours(TestData.Commands.UpdateMerchantOpeningHoursCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantOpeningHours(TestData.Commands.UpdateMerchantOpeningHoursCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -620,7 +620,7 @@ public async Task MerchantDomainService_UpdateMerchantOpeningHours_MerchantNotCr this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.UpdateMerchantOpeningHours(TestData.Commands.UpdateMerchantOpeningHoursCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantOpeningHours(TestData.Commands.UpdateMerchantOpeningHoursCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -633,7 +633,7 @@ public async Task MerchantDomainService_UpdateMerchantOpeningHours_EstateNotCrea this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantAggregate())); - var result = await this.DomainService.UpdateMerchantOpeningHours(TestData.Commands.UpdateMerchantOpeningHoursCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantOpeningHours(TestData.Commands.UpdateMerchantOpeningHoursCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -653,7 +653,7 @@ public async Task MerchantDomainService_CreateMerchantSchedule_Success() .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.AggregateService.Verify(m => m.Save(It.Is(aggregate => @@ -669,7 +669,7 @@ public async Task MerchantDomainService_CreateMerchantSchedule_GetEstateFailed_R this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -682,7 +682,7 @@ public async Task MerchantDomainService_CreateMerchantSchedule_GetMerchantFailed this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -697,7 +697,7 @@ public async Task MerchantDomainService_CreateMerchantSchedule_GetScheduleFailed this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -718,7 +718,7 @@ public async Task MerchantDomainService_CreateMerchantSchedule_SaveFailed_Result .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantSchedule(TestData.Commands.CreateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -739,7 +739,7 @@ public async Task MerchantDomainService_UpdateMerchantSchedule_Success() .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); this.AggregateService.Verify(m => m.Save(It.Is(aggregate => @@ -752,7 +752,7 @@ public async Task MerchantDomainService_UpdateMerchantSchedule_GetEstateFailed_R this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -765,7 +765,7 @@ public async Task MerchantDomainService_UpdateMerchantSchedule_GetMerchantFailed this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -780,7 +780,7 @@ public async Task MerchantDomainService_UpdateMerchantSchedule_GetScheduleFailed this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -795,7 +795,7 @@ public async Task MerchantDomainService_UpdateMerchantSchedule_ScheduleNotCreate this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantScheduleAggregate())); - var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -816,7 +816,7 @@ public async Task MerchantDomainService_UpdateMerchantSchedule_SaveFailed_Result .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantSchedule(TestData.Commands.UpdateMerchantScheduleCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -842,7 +842,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_WithdrawalIsMade( this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState))); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -868,7 +868,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_DuplicateWithdraw this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState))); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -885,7 +885,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_GetDepositListFai .Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -897,7 +897,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_EstateNotCreated_ this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantAggregate())); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -909,7 +909,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_MerchantNotCreate this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -925,7 +925,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_MerchantDepositLi .Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantDepositListAggregate)); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -947,7 +947,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_NotEnoughFundsToW this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionStateNoCredit))); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -966,7 +966,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_InvalidBalancePro this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success("null")); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -985,7 +985,7 @@ public async Task MerchantDomainService_AddContractToMerchant_ContractAdded() { TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(CalculationType.Fixed, FeeType.Merchant)); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1002,7 +1002,7 @@ public async Task MerchantDomainService_AddContractToMerchant_ContractNotCreated this.AggregateService.Setup(c => c.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.Aggregates.EmptyContractAggregate()); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1020,7 +1020,7 @@ public async Task MerchantDomainService_AddContractToMerchant_GetContractFailed_ this.AggregateService.Setup(c => c.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.NotFound()); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1038,7 +1038,7 @@ public async Task MerchantDomainService_AddContractToMerchant_MerchantNotCreated .ReturnsAsync(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(CalculationType.Fixed, FeeType.Merchant)); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1056,7 +1056,7 @@ public async Task MerchantDomainService_AddContractToMerchant_EstateNotCreated_E .ReturnsAsync(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(CalculationType.Fixed, FeeType.Merchant)); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1079,7 +1079,7 @@ public async Task MerchantDomainService_UpdateMerchant_MerchantIsUpdated( command.RequestDto.SettlementSchedule = settlementSchedule; - var result = await this.DomainService.UpdateMerchant(command, CancellationToken.None); + var result = await this.DomainService.UpdateMerchant(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1097,7 +1097,7 @@ public async Task MerchantDomainService_UpdateMerchant_ValidationError_ResultIsF MerchantCommands.UpdateMerchantCommand command = TestData.Commands.UpdateMerchantCommand; - var result = await this.DomainService.UpdateMerchant(command, CancellationToken.None); + var result = await this.DomainService.UpdateMerchant(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1112,7 +1112,7 @@ public async Task MerchantDomainService_AddMerchantAddress_AddressAdded() { .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1128,7 +1128,7 @@ public async Task MerchantDomainService_AddMerchantAddress_ValidationFailure_Res .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1143,7 +1143,7 @@ public async Task MerchantDomainService_UpdateMerchantAddress_AddressUpdated() { .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1159,7 +1159,7 @@ public async Task MerchantDomainService_UpdateMerchantAddress_ValidationFailed_R .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1174,7 +1174,7 @@ public async Task MerchantDomainService_AddMerchantContact_ContactAdded() { .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1190,7 +1190,7 @@ public async Task MerchantDomainService_AddMerchantContact_ValidationError_Resul .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1205,7 +1205,7 @@ public async Task MerchantDomainService_UpdateMerchantContact_ContactUpdated() { .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1221,7 +1221,7 @@ public async Task MerchantDomainService_UpdateMerchantContact_ValidationError_Re .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1236,7 +1236,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_OperatorRemov .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1252,7 +1252,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_ValidationFai .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1267,7 +1267,7 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_ContractRemov .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -1283,7 +1283,7 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_ValidationFai .Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success); - var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1292,7 +1292,7 @@ public async Task MerchantDomainService_CreateMerchant_GetEstateFailed_ResultIsF this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1303,7 +1303,7 @@ public async Task MerchantDomainService_CreateMerchant_GetMerchantFailed_ResultI this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1316,7 +1316,7 @@ public async Task MerchantDomainService_CreateMerchant_SaveFailed_ResultIsFailed this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1325,7 +1325,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_GetEstateFailed this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1336,7 +1336,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_GetMerchantFail this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1349,7 +1349,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_GetOperatorFail this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1365,7 +1365,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_StateChangeFail this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1380,7 +1380,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_SaveFailed_Resu this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1389,7 +1389,7 @@ public async Task MerchantDomainService_CreateMerchantUser_GetEstateFailed_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1400,7 +1400,7 @@ public async Task MerchantDomainService_CreateMerchantUser_GetMerchantFailed_Res this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1417,7 +1417,7 @@ public async Task MerchantDomainService_CreateMerchantUser_SaveFailed_ResultIsFa this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1426,7 +1426,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_GetEstateFailed_Resu this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1437,7 +1437,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_GetMerchantFailed_Re this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1451,7 +1451,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_StateChangeFailed_Re this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1464,7 +1464,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_SaveFailed_ResultIsF this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1473,7 +1473,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_GetEstateFailed_Resu this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1484,7 +1484,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_GetMerchantFailed_Re this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1493,7 +1493,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_GetEstateFailed_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1504,7 +1504,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_GetMerchantFailed_Res this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1522,7 +1522,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_StateChangedFailed_Re DeviceIdentifier = String.Empty }; - var result = await this.DomainService.SwapMerchantDevice(command, CancellationToken.None); + var result = await this.DomainService.SwapMerchantDevice(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1535,7 +1535,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_SaveFailed_ResultIsFa this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1544,7 +1544,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_GetEstateFailed_R this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1555,7 +1555,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_GetMerchantFailed this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1571,7 +1571,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_GetBalanceFailed_ this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1589,7 +1589,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_SaveFailed_Result this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1598,7 +1598,7 @@ public async Task MerchantDomainService_AddContractToMerchant_GetEstateFailed_Re this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1609,7 +1609,7 @@ public async Task MerchantDomainService_AddContractToMerchant_GetMerchantFailed_ this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1625,7 +1625,7 @@ public async Task MerchantDomainService_AddContractToMerchant_StateChangeFailed_ this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1640,7 +1640,7 @@ public async Task MerchantDomainService_AddContractToMerchant_SaveFailed_ResultI this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1649,7 +1649,7 @@ public async Task MerchantDomainService_UpdateMerchant_GetEstateFailed_ResultIsF this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1660,7 +1660,7 @@ public async Task MerchantDomainService_UpdateMerchant_GetMerchantFailed_ResultI this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1671,7 +1671,7 @@ public async Task MerchantDomainService_UpdateMerchant_MerchantNotCreated_Result this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1687,7 +1687,7 @@ public async Task MerchantDomainService_UpdateMerchant_SaveFailed_ResultIsFailed MerchantCommands.UpdateMerchantCommand command = TestData.Commands.UpdateMerchantCommand; command.RequestDto.SettlementSchedule = DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate; - var result = await this.DomainService.UpdateMerchant(command, CancellationToken.None); + var result = await this.DomainService.UpdateMerchant(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1696,7 +1696,7 @@ public async Task MerchantDomainService_AddMerchantAddress_GetEstateFailed_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1707,7 +1707,7 @@ public async Task MerchantDomainService_AddMerchantAddress_GetMerchantFailed_Res this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1718,7 +1718,7 @@ public async Task MerchantDomainService_AddMerchantAddress_MerchantNotCreated_Re this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1731,7 +1731,7 @@ public async Task MerchantDomainService_AddMerchantAddress_SaveFailed_ResultIsFa this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1740,7 +1740,7 @@ public async Task MerchantDomainService_UpdateMerchantAddress_GetEstateFailed_Re this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1751,7 +1751,7 @@ public async Task MerchantDomainService_UpdateMerchantAddress_GetMerchantFailed_ this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1762,7 +1762,7 @@ public async Task MerchantDomainService_UpdateMerchantAddress_MerchantNotCreated this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1775,7 +1775,7 @@ public async Task MerchantDomainService_UpdateMerchantAddress_SaveFailed_ResultI this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1784,7 +1784,7 @@ public async Task MerchantDomainService_AddMerchantContact_GetEstateFailed_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1795,7 +1795,7 @@ public async Task MerchantDomainService_AddMerchantContact_GetMerchantFailed_Res this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1806,7 +1806,7 @@ public async Task MerchantDomainService_AddMerchantContact_MerchantNotCreated_Re this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1819,7 +1819,7 @@ public async Task MerchantDomainService_AddMerchantContact_SaveFailed_ResultIsFa this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1828,7 +1828,7 @@ public async Task MerchantDomainService_UpdateMerchantContact_GetEstateFailed_Re this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1839,7 +1839,7 @@ public async Task MerchantDomainService_UpdateMerchantContact_GetMerchantFailed_ this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1850,7 +1850,7 @@ public async Task MerchantDomainService_UpdateMerchantContact_MerchantNotCreated this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1863,7 +1863,7 @@ public async Task MerchantDomainService_UpdateMerchantContact_SaveFailed_ResultI this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1872,7 +1872,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_GetEstateFail this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1883,7 +1883,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_GetMerchantFa this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1894,7 +1894,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_MerchantNotCr this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1910,7 +1910,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_StateChangeFa var command = TestData.Commands.RemoveOperatorFromMerchantCommand with { OperatorId = Guid.NewGuid() }; - var result = await this.DomainService.RemoveOperatorFromMerchant(command, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1923,7 +1923,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_SaveFailed_Re this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1932,7 +1932,7 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_GetEstateFail this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1943,7 +1943,7 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_GetMerchantFa this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1954,7 +1954,7 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_MerchantNotCr this.AggregateService.Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); - var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1970,7 +1970,7 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_StateChangeFa var command = TestData.Commands.RemoveMerchantContractCommand with { ContractId = Guid.NewGuid() }; - var result = await this.DomainService.RemoveContractFromMerchant(command, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1983,7 +1983,7 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_SaveFailed_Re this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1999,7 +1999,7 @@ public async Task MerchantDomainService_CreateMerchant_NotSetSettlementSchedule_ MerchantCommands.CreateMerchantCommand command = TestData.Commands.CreateMerchantCommand; command.RequestDto.SettlementSchedule = DataTransferObjects.Responses.Merchant.SettlementSchedule.NotSet; - var result = await this.DomainService.CreateMerchant(command, CancellationToken.None); + var result = await this.DomainService.CreateMerchant(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2019,7 +2019,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_AutomaticDepositSour MerchantCommands.MakeMerchantDepositCommand command = new(TestData.EstateId, TestData.MerchantId, TestData.MerchantDepositSourceAutomaticDTO, TestData.MakeMerchantDepositRequest); - var result = await this.DomainService.MakeMerchantDeposit(command, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -2028,7 +2028,7 @@ public async Task MerchantDomainService_CreateMerchant_ExceptionThrown_ResultIsF this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchant(TestData.Commands.CreateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2037,7 +2037,7 @@ public async Task MerchantDomainService_AssignOperatorToMerchant_ExceptionThrown this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, CancellationToken.None); + var result = await this.DomainService.AssignOperatorToMerchant(TestData.Commands.AssignOperatorToMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2046,7 +2046,7 @@ public async Task MerchantDomainService_CreateMerchantUser_ExceptionThrown_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, CancellationToken.None); + var result = await this.DomainService.CreateMerchantUser(TestData.Commands.CreateMerchantUserCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2055,7 +2055,7 @@ public async Task MerchantDomainService_AddDeviceToMerchant_ExceptionThrown_Resu this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.AddDeviceToMerchant(TestData.Commands.AddMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2064,7 +2064,7 @@ public async Task MerchantDomainService_MakeMerchantDeposit_ExceptionThrown_Resu this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantDeposit(TestData.Commands.MakeMerchantDepositCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2073,7 +2073,7 @@ public async Task MerchantDomainService_SwapMerchantDevice_ExceptionThrown_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, CancellationToken.None); + var result = await this.DomainService.SwapMerchantDevice(TestData.Commands.SwapMerchantDeviceCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2082,7 +2082,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_ExceptionThrown_R this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); + var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2091,7 +2091,7 @@ public async Task MerchantDomainService_AddContractToMerchant_ExceptionThrown_Re this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.AddContractToMerchant(TestData.Commands.AddMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2100,7 +2100,7 @@ public async Task MerchantDomainService_UpdateMerchant_ExceptionThrown_ResultIsF this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchant(TestData.Commands.UpdateMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2109,7 +2109,7 @@ public async Task MerchantDomainService_AddMerchantAddress_ExceptionThrown_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantAddress(TestData.Commands.AddMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2118,7 +2118,7 @@ public async Task MerchantDomainService_UpdateMerchantAddress_ExceptionThrown_Re this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantAddress(TestData.Commands.UpdateMerchantAddressCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2127,7 +2127,7 @@ public async Task MerchantDomainService_AddMerchantContact_ExceptionThrown_Resul this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.AddMerchantContact(TestData.Commands.AddMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2136,7 +2136,7 @@ public async Task MerchantDomainService_UpdateMerchantContact_ExceptionThrown_Re this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, CancellationToken.None); + var result = await this.DomainService.UpdateMerchantContact(TestData.Commands.UpdateMerchantContactCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2145,7 +2145,7 @@ public async Task MerchantDomainService_RemoveOperatorFromMerchant_ExceptionThro this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, CancellationToken.None); + var result = await this.DomainService.RemoveOperatorFromMerchant(TestData.Commands.RemoveOperatorFromMerchantCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -2154,7 +2154,8 @@ public async Task MerchantDomainService_RemoveContractFromMerchant_ExceptionThro this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Test exception")); - var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, CancellationToken.None); + var result = await this.DomainService.RemoveContractFromMerchant(TestData.Commands.RemoveMerchantContractCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs index c52ff69f..0dfcd594 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs @@ -1,4 +1,4 @@ -using MessagingService.Client; +using MessagingService.Client; using MessagingService.DataTransferObjects; using Microsoft.Extensions.Configuration; using Moq; @@ -48,7 +48,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_Trans 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.Success()); - Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -58,7 +58,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_Trans 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.Success()); - Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionNotAuthorisedToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionNotAuthorisedToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -68,7 +68,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_Trans 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.Success()); - Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionWithNoAmountToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionWithNoAmountToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -78,7 +78,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_SaveF 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.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -87,7 +87,7 @@ public async Task MerchantStatementDomainService_AddSettledFeeToStatement_Settle { 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.Success()); - Result result = await this.DomainService.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -96,7 +96,7 @@ public async Task MerchantStatementDomainService_AddSettledFeeToStatement_SaveFa { 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.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -106,7 +106,7 @@ public async Task MerchantStatementDomainService_AddDepositToStatement_DepositAd 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.Success()); - Result result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -116,7 +116,7 @@ public async Task MerchantStatementDomainService_AddWithdrawalToStatement_Withdr 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.Success()); - Result result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -124,7 +124,7 @@ public async Task MerchantStatementDomainService_AddWithdrawalToStatement_Withdr public async Task MerchantStatementDomainService_RecordActivityDateOnMerchantStatement_SaveFailed_ActivityDateNotRecorded() { this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantStatementAggregate)); this.AggregateService.Setup(a => a.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); - Result result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -133,7 +133,7 @@ public async Task MerchantStatementDomainService_RecordActivityDateOnMerchantSta { this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantStatementAggregate)); this.AggregateService.Setup(a => a.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure); - Result result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -145,7 +145,7 @@ public async Task MerchantStatementDomainService_GenerateStatement_StatementIsGe this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantStatementForDateAggregateWithTransactionAndFee())); - Result result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -157,7 +157,7 @@ public async Task MerchantStatementDomainService_GenerateStatement_GetStatementF 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 result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -169,7 +169,7 @@ public async Task MerchantStatementDomainService_GenerateStatement_SaveFailed_St this.AggregateService.Setup(a => a.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantStatementForDateAggregateWithTransactionAndFee())); - Result result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -185,7 +185,7 @@ public async Task MerchantStatementDomainService_BuildStatement_StatementIsBuilt this.StatementBuilder.Setup(s => s.GetStatementHtml(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(""); - Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -201,7 +201,7 @@ public async Task MerchantStatementDomainService_BuildStatement_GetMerchantFaile this.StatementBuilder.Setup(s => s.GetStatementHtml(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(""); - Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -217,7 +217,7 @@ public async Task MerchantStatementDomainService_BuildStatement_MerchantNotCreat this.StatementBuilder.Setup(s => s.GetStatementHtml(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(""); - Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -233,7 +233,7 @@ public async Task MerchantStatementDomainService_BuildStatement_SaveFailed_State this.StatementBuilder.Setup(s => s.GetStatementHtml(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(""); - Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -249,7 +249,7 @@ public async Task MerchantStatementDomainService_EmailStatement_StatementIsEmail this.SecurityServiceClient.Setup(m => m.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetTokenResponse())); - Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -265,7 +265,7 @@ public async Task MerchantStatementDomainService_EmailStatement_MerchantNotFound this.SecurityServiceClient.Setup(m => m.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetTokenResponse())); - Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -281,7 +281,7 @@ public async Task MerchantStatementDomainService_EmailStatement_GetTokenFailed_S this.SecurityServiceClient.Setup(m => m.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); - Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -289,7 +289,7 @@ public async Task MerchantStatementDomainService_EmailStatement_GetTokenFailed_S 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 result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -297,7 +297,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_GetSt 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 result = await this.DomainService.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -306,7 +306,7 @@ public async Task MerchantStatementDomainService_AddDepositToStatement_SaveFaile { 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 result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -314,7 +314,7 @@ public async Task MerchantStatementDomainService_AddDepositToStatement_SaveFaile 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 result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -323,7 +323,7 @@ public async Task MerchantStatementDomainService_AddWithdrawalToStatement_SaveFa { 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 result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -331,7 +331,7 @@ public async Task MerchantStatementDomainService_AddWithdrawalToStatement_SaveFa 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 result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -339,7 +339,7 @@ public async Task MerchantStatementDomainService_AddWithdrawalToStatement_GetSta 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 result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -347,7 +347,7 @@ public async Task MerchantStatementDomainService_RecordActivityDateOnMerchantSta 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 result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -355,7 +355,7 @@ public async Task MerchantStatementDomainService_GenerateStatement_GetStatementF 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 result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -369,7 +369,7 @@ public async Task MerchantStatementDomainService_BuildStatement_GetStatementHtml 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 result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -377,7 +377,7 @@ public async Task MerchantStatementDomainService_BuildStatement_GetStatementHtml 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 result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -393,7 +393,7 @@ public async Task MerchantStatementDomainService_EmailStatement_SaveFailed_State this.SecurityServiceClient.Setup(m => m.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.GetTokenResponse())); - Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, CancellationToken.None); + Result result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -401,7 +401,7 @@ public async Task MerchantStatementDomainService_EmailStatement_SaveFailed_State 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 result = await this.DomainService.AddTransactionToStatement(TestData.Commands.AddTransactionToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -409,7 +409,7 @@ public async Task MerchantStatementDomainService_AddTransactionToStatement_Excep 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 result = await this.DomainService.AddSettledFeeToStatement(TestData.Commands.AddSettledFeeToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -417,7 +417,7 @@ public async Task MerchantStatementDomainService_AddSettledFeeToStatement_Except 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 result = await this.DomainService.AddDepositToStatement(TestData.Commands.AddDepositToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -425,7 +425,7 @@ public async Task MerchantStatementDomainService_AddDepositToStatement_Exception 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 result = await this.DomainService.AddWithdrawalToStatement(TestData.Commands.AddWithdrawalToMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -433,7 +433,7 @@ public async Task MerchantStatementDomainService_AddWithdrawalToStatement_Except 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 result = await this.DomainService.RecordActivityDateOnMerchantStatement(TestData.Commands.RecordActivityDateOnMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -441,7 +441,7 @@ public async Task MerchantStatementDomainService_RecordActivityDateOnMerchantSta 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 result = await this.DomainService.GenerateStatement(TestData.Commands.GenerateMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -449,7 +449,7 @@ public async Task MerchantStatementDomainService_GenerateStatement_ExceptionThro 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 result = await this.DomainService.BuildStatement(TestData.Commands.BuildMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -457,9 +457,9 @@ public async Task MerchantStatementDomainService_BuildStatement_ExceptionThrown_ 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 result = await this.DomainService.EmailStatement(TestData.Commands.EmailMerchantStatementCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs index 29a092fe..db01df9e 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs @@ -1,4 +1,4 @@ -using Moq; +using Moq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.Serialisation; @@ -37,7 +37,7 @@ public async Task OperatorDomainService_CreateOperator_OperatorIsCreated(){ this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.EmptyOperatorAggregate())); this.AggregateService .Setup(o => o.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); - Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -60,7 +60,7 @@ public async Task OperatorDomainService_CreateOperator_OperatorIdIsEmpty_Operato RequireCustomTerminalNumber = TestData.RequireCustomTerminalNumber }); - Result result = await this.OperatorDomainService.CreateOperator(emptyIdCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(emptyIdCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -71,7 +71,7 @@ public async Task OperatorDomainService_CreateOperator_EstateNotCreated_ResultFa .ReturnsAsync(TestData.Aggregates.EmptyEstateAggregate); this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.EmptyOperatorAggregate())); - Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -83,7 +83,7 @@ public async Task OperatorDomainService_CreateOperator_OperatorAlreadyCreated_Re this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); - Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -103,7 +103,7 @@ public async Task OperatorDomainService_CreateOperator_OperatorNameEmpty_ResultF RequireCustomTerminalNumber = TestData.RequireCustomTerminalNumber }); - Result result = await this.OperatorDomainService.CreateOperator(emptyNameCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(emptyNameCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -115,7 +115,7 @@ public async Task OperatorDomainService_UpdateOperator_OperatorIsUpdated() this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); this.AggregateService .Setup(o => o.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success()); - Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -126,7 +126,7 @@ public async Task OperatorDomainService_UpdateOperator_OperatorNotCreated_Result .ReturnsAsync(TestData.Aggregates.CreatedEstateAggregate()); this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.EmptyOperatorAggregate())); - Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -136,7 +136,7 @@ public async Task OperatorDomainService_CreateOperator_GetEstateFailed_ResultFai this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -148,7 +148,7 @@ public async Task OperatorDomainService_CreateOperator_GetOperatorFailed_ResultF this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -162,7 +162,7 @@ public async Task OperatorDomainService_CreateOperator_SaveFailed_ResultFailed() this.AggregateService.Setup(o => o.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -172,7 +172,7 @@ public async Task OperatorDomainService_CreateOperator_ExceptionThrown_ResultFai this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception()); - Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.CreateOperator(TestData.Commands.CreateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -182,7 +182,7 @@ public async Task OperatorDomainService_UpdateOperator_GetEstateFailed_ResultFai this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -194,7 +194,7 @@ public async Task OperatorDomainService_UpdateOperator_EstateNotCreated_ResultFa this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(SimpleResults.Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); - Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -206,7 +206,7 @@ public async Task OperatorDomainService_UpdateOperator_GetOperatorFailed_ResultF this.AggregateService.Setup(o => o.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -220,7 +220,7 @@ public async Task OperatorDomainService_UpdateOperator_SaveFailed_ResultFailed() this.AggregateService.Setup(o => o.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); - Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -230,7 +230,7 @@ public async Task OperatorDomainService_UpdateOperator_ExceptionThrown_ResultFai this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception()); - Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, CancellationToken.None); + Result result = await this.OperatorDomainService.UpdateOperator(TestData.Commands.UpdateOperatorCommand, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs index 48abb388..5e2caf0c 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs @@ -1,4 +1,4 @@ -using SimpleResults; +using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Requests; using TransactionProcessor.Models.Contract; @@ -80,7 +80,7 @@ public async Task SettlementDomainService_ProcessSettlement_SettlementIsProcesse new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBe(Guid.Empty); @@ -128,7 +128,7 @@ public async Task SettlementDomainService_ProcessSettlement_RunOutOfRetries_Sett new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeFalse(); this.AggregateService.Verify(s => s.Save(It.IsAny(), It.IsAny()), Times.Exactly(7)); @@ -172,7 +172,7 @@ public async Task SettlementDomainService_ProcessSettlement_RetryOnWrongExpected new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBe(Guid.Empty); @@ -218,7 +218,7 @@ public async Task SettlementDomainService_ProcessSettlement_MerchantWithImmediat new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBe(Guid.Empty); @@ -237,7 +237,7 @@ public async Task SettlementDomainService_ProcessSettlement_SettlementAggregateN new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -256,7 +256,7 @@ public async Task SettlementDomainService_ProcessSettlement_SettlementAggregateN SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBe(Guid.Empty); @@ -299,7 +299,7 @@ public async Task SettlementDomainService_ProcessSettlement_AddSettledFeeThrownE SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -320,7 +320,7 @@ public async Task SettlementDomainService_ProcessSettlement_GetTransactionThrown SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -338,7 +338,7 @@ public async Task SettlementDomainService_ProcessSettlement_GetMerchantThrownExc SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -352,7 +352,7 @@ public async Task SettlementDomainService_AddMerchantFeePendingSettlement_FeeAdd SettlementCommands.AddMerchantFeePendingSettlementCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.TransactionFeeValue, TestData.TransactionFeeSettlementDueDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -367,7 +367,7 @@ public async Task SettlementDomainService_AddMerchantFeePendingSettlement_Aggreg SettlementCommands.AddMerchantFeePendingSettlementCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.TransactionFeeValue, TestData.TransactionFeeSettlementDueDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -384,7 +384,7 @@ public async Task SettlementDomainService_AddSettledFeeToSettlement_FeeAdded() SettlementCommands.AddSettledFeeToSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId, TestData.TransactionFeeId, TestData.TransactionId); - Result result = await settlementDomainService.AddSettledFeeToSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddSettledFeeToSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -401,7 +401,7 @@ public async Task SettlementDomainService_AddSettledFeeToSettlement_ImmediateSet SettlementCommands.AddSettledFeeToSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId, TestData.TransactionFeeId, TestData.TransactionId); - Result result = await settlementDomainService.AddSettledFeeToSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddSettledFeeToSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -418,7 +418,7 @@ public async Task SettlementDomainService_AddSettledFeeToSettlement_FailedGettin SettlementCommands.AddSettledFeeToSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId, TestData.TransactionFeeId, TestData.TransactionId); - Result result = await settlementDomainService.AddSettledFeeToSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddSettledFeeToSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -435,7 +435,7 @@ public async Task SettlementDomainService_AddSettledFeeToSettlement_SaveFailed_F SettlementCommands.AddSettledFeeToSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId, TestData.TransactionFeeId, TestData.TransactionId); - Result result = await settlementDomainService.AddSettledFeeToSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddSettledFeeToSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -452,7 +452,7 @@ public async Task SettlementDomainService_AddSettledFeeToSettlement_ExceptionThr SettlementCommands.AddSettledFeeToSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId, TestData.TransactionFeeId, TestData.TransactionId); - Result result = await settlementDomainService.AddSettledFeeToSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddSettledFeeToSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -464,7 +464,7 @@ public async Task SettlementDomainService_ProcessSettlement_GetSettlementAggrega SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -479,7 +479,7 @@ public async Task SettlementDomainService_ProcessSettlement_GetMerchantFailed_Se SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -498,7 +498,7 @@ public async Task SettlementDomainService_ProcessSettlement_GetTransactionFailed SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -515,7 +515,7 @@ public async Task SettlementDomainService_ProcessSettlement_SaveSettlementAggreg SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -554,7 +554,7 @@ public async Task SettlementDomainService_ProcessSettlement_WithScheduledSettlem SettlementCommands.ProcessSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.ProcessSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.ProcessSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBe(Guid.Empty); @@ -568,7 +568,7 @@ public async Task SettlementDomainService_AddMerchantFeePendingSettlement_GetSet SettlementCommands.AddMerchantFeePendingSettlementCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.TransactionFeeValue, TestData.TransactionFeeSettlementDueDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -583,7 +583,7 @@ public async Task SettlementDomainService_AddMerchantFeePendingSettlement_StateC SettlementCommands.AddMerchantFeePendingSettlementCommand command = new(Guid.Empty, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.TransactionFeeValue, TestData.TransactionFeeSettlementDueDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -598,7 +598,7 @@ public async Task SettlementDomainService_AddMerchantFeePendingSettlement_SaveFa SettlementCommands.AddMerchantFeePendingSettlementCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.TransactionFeeValue, TestData.TransactionFeeSettlementDueDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -611,7 +611,7 @@ public async Task SettlementDomainService_AddMerchantFeePendingSettlement_Except SettlementCommands.AddMerchantFeePendingSettlementCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.TransactionFeeValue, TestData.TransactionFeeSettlementDueDate, TestData.MerchantId, TestData.EstateId); - Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddMerchantFeePendingSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -624,7 +624,7 @@ public async Task SettlementDomainService_AddSettledFeeToSettlement_GetSettlemen SettlementCommands.AddSettledFeeToSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId, TestData.TransactionFeeId, TestData.TransactionId); - Result result = await settlementDomainService.AddSettledFeeToSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddSettledFeeToSettlement(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -641,9 +641,10 @@ public async Task SettlementDomainService_AddSettledFeeToSettlement_WithSchedule SettlementCommands.AddSettledFeeToSettlementCommand command = new(TestData.SettlementDate, TestData.MerchantId, TestData.EstateId, TestData.TransactionFeeId, TestData.TransactionId); - Result result = await settlementDomainService.AddSettledFeeToSettlement(command, CancellationToken.None); + Result result = await settlementDomainService.AddSettledFeeToSettlement(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs index feedd975..c8ef1400 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs @@ -23,7 +23,7 @@ public class StatementBuilderTests { private readonly StatementBuilder _builder; private readonly MerchantStatementAggregate merchantStatementAggregate; private readonly Merchant _merchant; - private readonly CancellationToken _cancellationToken = CancellationToken.None; + private readonly CancellationToken _cancellationToken = TestContext.Current.CancellationToken; public StatementBuilderTests() { StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); @@ -137,3 +137,4 @@ public async Task GetStatementHtml_ThrowsIfMerchantContactMissing() { } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs index 467e34a9..0bad56ac 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs @@ -1,4 +1,4 @@ -using MessagingService.DataTransferObjects; +using MessagingService.DataTransferObjects; using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; @@ -98,7 +98,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_DeviceNeedsAd TestData.TransactionDateTime, TestData.TransactionNumber, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessLogonTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessLogonTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.EstateId.ShouldBe(TestData.EstateId); @@ -129,7 +129,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_TransactionIs TestData.TransactionDateTime, TestData.TransactionNumber, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessLogonTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessLogonTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.EstateId.ShouldBe(TestData.EstateId); @@ -160,7 +160,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_ValidationFai TestData.TransactionDateTime, TestData.TransactionNumber, TestData.TransactionReceivedDateTime); - Result result = await this.TransactionDomainService.ProcessLogonTransaction(command, CancellationToken.None); + Result result = await this.TransactionDomainService.ProcessLogonTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.EstateId.ShouldBe(TestData.EstateId); @@ -185,7 +185,7 @@ public async Task TransactionDomainService_ProcessReconciliationTransaction_Reco TestData.MerchantId, TestData.DeviceIdentifier, TestData.TransactionDateTime, TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); - var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); ProcessReconciliationTransactionResponse response = result.Data; @@ -215,7 +215,7 @@ public async Task TransactionDomainService_ProcessReconciliationTransaction_Vali TestData.MerchantId, TestData.DeviceIdentifier, TestData.TransactionDateTime, TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); - var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); var response = result.Data; @@ -269,7 +269,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_DeclinedByOper TestData.CustomerEmailAddress, TestData.AdditionalTransactionMetaDataForMobileTopup(), TestData.ContractId, TestData.ProductId, TestData.TransactionSource, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessSaleTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessSaleTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); var response = result.Data; @@ -312,7 +312,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_OperatorProxyT TestData.CustomerEmailAddress, TestData.AdditionalTransactionMetaDataForMobileTopup(), TestData.ContractId, TestData.ProductId, TestData.TransactionSource, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessSaleTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessSaleTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); var response = result.Data; @@ -372,7 +372,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_TransactionIsP TestData.CustomerEmailAddress, TestData.AdditionalTransactionMetaDataForMobileTopup(), TestData.ContractId, TestData.ProductId, TestData.TransactionSource, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessSaleTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessSaleTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); var response = result.Data; @@ -436,7 +436,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_NoFloatFound_T TestData.CustomerEmailAddress, TestData.AdditionalTransactionMetaDataForMobileTopup(), TestData.ContractId, TestData.ProductId, TestData.TransactionSource, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessSaleTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessSaleTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); var response = result.Data; @@ -480,7 +480,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_ValidationFail TestData.CustomerEmailAddress, TestData.AdditionalTransactionMetaDataForMobileTopup(), TestData.ContractId, TestData.ProductId, TestData.TransactionSource, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessSaleTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessSaleTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); var response = result.Data; @@ -497,7 +497,7 @@ public async Task TransactionDomainService_ResendTransactionReceipt_TransactionR this.AggregateService.Setup(t => t.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success()); TransactionCommands.ResendTransactionReceiptCommand command = new(TestData.TransactionId, TestData.EstateId); - var result = await this.TransactionDomainService.ResendTransactionReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.ResendTransactionReceipt(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -602,7 +602,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_FeesCalcu TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -618,7 +618,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_MerchantW TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -635,7 +635,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_NonMercha TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -651,7 +651,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_Transacti TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -670,7 +670,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_NoFeesRet TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -681,7 +681,7 @@ public async Task TransactionDomainService_AddSettledMerchantFee_FeeAdded() { TransactionCommands.AddSettledMerchantFeeCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.CalculatedFeeValue, TestData.SettlementDate, TestData.SettlementAggregateId); - var result = await this.TransactionDomainService.AddSettledMerchantFee(command, CancellationToken.None); + var result = await this.TransactionDomainService.AddSettledMerchantFee(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -693,7 +693,7 @@ public async Task TransactionDomainService_AddSettledMerchantFee_SaveFailed_Resu TransactionCommands.AddSettledMerchantFeeCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.CalculatedFeeValue, TestData.SettlementDate, TestData.SettlementAggregateId); - var result = await this.TransactionDomainService.AddSettledMerchantFee(command, CancellationToken.None); + var result = await this.TransactionDomainService.AddSettledMerchantFee(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -707,7 +707,7 @@ public async Task TransactionDomainService_SendCustomerEmailReceipt_ReceiptSent( this.TransactionReceiptBuilder.Setup(r => r.GetEmailReceiptMessage(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync("EmailMessage"); this.MessagingServiceClient.Setup(m => m.SendEmail(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); TransactionCommands.SendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId, Guid.NewGuid(), TestData.CustomerEmailAddress); - var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -718,7 +718,7 @@ public async Task TransactionDomainService_SendCustomerEmailReceipt_GetTransacti this.AggregateService.Setup(t => t.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); TransactionCommands.SendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId, Guid.NewGuid(), TestData.CustomerEmailAddress); - var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -730,7 +730,7 @@ public async Task TransactionDomainService_ResendCustomerEmailReceipt_ReceiptSen this.MessagingServiceClient.Setup(m => m.ResendEmail(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); TransactionCommands.ResendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId); - var result = await this.TransactionDomainService.ResendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.ResendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -741,7 +741,7 @@ public async Task TransactionDomainService_ResendCustomerEmailReceipt_GetTransac this.AggregateService.Setup(t => t.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); TransactionCommands.ResendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId); - var result = await this.TransactionDomainService.ResendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.ResendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -759,7 +759,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_GetAggregateF TestData.TransactionDateTime, TestData.TransactionNumber, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessLogonTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessLogonTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -783,7 +783,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_SaveFailed_Re TestData.TransactionDateTime, TestData.TransactionNumber, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessLogonTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessLogonTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -798,7 +798,7 @@ public async Task TransactionDomainService_ProcessReconciliationTransaction_GetA TestData.MerchantId, TestData.DeviceIdentifier, TestData.TransactionDateTime, TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); - var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -819,7 +819,7 @@ public async Task TransactionDomainService_ProcessReconciliationTransaction_Save TestData.MerchantId, TestData.DeviceIdentifier, TestData.TransactionDateTime, TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); - var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessReconciliationTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -830,7 +830,7 @@ public async Task TransactionDomainService_ResendTransactionReceipt_GetAggregate .ReturnsAsync(Result.Failure()); TransactionCommands.ResendTransactionReceiptCommand command = new(TestData.TransactionId, TestData.EstateId); - var result = await this.TransactionDomainService.ResendTransactionReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.ResendTransactionReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -843,7 +843,7 @@ public async Task TransactionDomainService_ResendTransactionReceipt_SaveFailed_R .ReturnsAsync(Result.Failure()); TransactionCommands.ResendTransactionReceiptCommand command = new(TestData.TransactionId, TestData.EstateId); - var result = await this.TransactionDomainService.ResendTransactionReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.ResendTransactionReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -860,7 +860,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_GetAggregateFa TestData.CustomerEmailAddress, TestData.AdditionalTransactionMetaDataForMobileTopup(), TestData.ContractId, TestData.ProductId, TestData.TransactionSource, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessSaleTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessSaleTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -904,7 +904,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_SaveFailed_Res TestData.CustomerEmailAddress, TestData.AdditionalTransactionMetaDataForMobileTopup(), TestData.ContractId, TestData.ProductId, TestData.TransactionSource, TestData.TransactionReceivedDateTime); - var result = await this.TransactionDomainService.ProcessSaleTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.ProcessSaleTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -916,7 +916,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_GetAggreg TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -932,7 +932,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_MerchantS TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -948,7 +948,7 @@ public async Task TransactionDomainService_CalculateFeesForTransaction_SaveFaile TransactionCommands.CalculateFeesForTransactionCommand command = new(TestData.TransactionId, TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); - var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, CancellationToken.None); + var result = await this.TransactionDomainService.CalculateFeesForTransaction(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -960,7 +960,7 @@ public async Task TransactionDomainService_AddSettledMerchantFee_GetAggregateFai TransactionCommands.AddSettledMerchantFeeCommand command = new(TestData.TransactionId, TestData.CalculatedFeeValue, TestData.TransactionFeeCalculateDateTime, CalculationType.Fixed, TestData.TransactionFeeId, TestData.CalculatedFeeValue, TestData.SettlementDate, TestData.SettlementAggregateId); - var result = await this.TransactionDomainService.AddSettledMerchantFee(command, CancellationToken.None); + var result = await this.TransactionDomainService.AddSettledMerchantFee(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -970,7 +970,7 @@ public async Task TransactionDomainService_SendCustomerEmailReceipt_GetTokenFail this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); TransactionCommands.SendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId, Guid.NewGuid(), TestData.CustomerEmailAddress); - var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -983,7 +983,7 @@ public async Task TransactionDomainService_SendCustomerEmailReceipt_GetMerchantF .ReturnsAsync(Result.Failure()); TransactionCommands.SendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId, Guid.NewGuid(), TestData.CustomerEmailAddress); - var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -997,7 +997,7 @@ public async Task TransactionDomainService_SendCustomerEmailReceipt_GetEstateFai this.AggregateService.Setup(c => c.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); TransactionCommands.SendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId, Guid.NewGuid(), TestData.CustomerEmailAddress); - var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.SendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -1007,10 +1007,11 @@ public async Task TransactionDomainService_ResendCustomerEmailReceipt_GetTokenFa this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); TransactionCommands.ResendCustomerEmailReceiptCommand command = new(TestData.EstateId, TestData.TransactionId); - var result = await this.TransactionDomainService.ResendCustomerEmailReceipt(command, CancellationToken.None); + var result = await this.TransactionDomainService.ResendCustomerEmailReceipt(command, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } #endregion } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs index 27181a77..7bd5bb9a 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace TransactionProcessor.BusinessLogic.Tests.Services @@ -40,7 +40,7 @@ public async Task TransactionReceiptBuilder_GetEmailReceiptMessage_MessageBuilt( TransactionReceiptBuilder receiptBuilder = new TransactionReceiptBuilder(fileSystem); - String receiptMessage = await receiptBuilder.GetEmailReceiptMessage(transaction, new Models.Merchant.Merchant(),"OperatorName", CancellationToken.None); + String receiptMessage = await receiptBuilder.GetEmailReceiptMessage(transaction, new Models.Merchant.Merchant(),"OperatorName", TestContext.Current.CancellationToken); receiptMessage.ShouldBe("Transaction Number: 12345"); @@ -48,3 +48,4 @@ public async Task TransactionReceiptBuilder_GetEmailReceiptMessage_MessageBuilt( } } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs index fb0aed30..156f2982 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs @@ -1,4 +1,4 @@ -using Shared.EventStore.Aggregate; +using Shared.EventStore.Aggregate; using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.Models.Merchant; @@ -50,7 +50,7 @@ public async Task ValidateLogonTransactionX_ValidationSuccessful_CorrectResponse .ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.Success); @@ -62,7 +62,7 @@ public async Task ValidateLogonTransactionX_InvalidEstate_CorrectResponseReturne .ReturnsAsync(Result.NotFound("Estate not found")); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidEstateId); @@ -75,7 +75,7 @@ public async Task ValidateLogonTransactionX_FailureWhileGettingEstate_CorrectRes .ReturnsAsync(Result.Failure("Failed")); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); @@ -90,7 +90,7 @@ public async Task ValidateLogonTransactionX_InvalidMerchant_CorrectResponseRetur .ReturnsAsync(Result.NotFound("Merchant Not Found")); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidMerchantId); @@ -105,7 +105,7 @@ public async Task ValidateLogonTransactionX_FailureWhileGettingMerchant_CorrectR .ReturnsAsync(Result.Failure("Merchant Not Found")); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); @@ -120,7 +120,7 @@ public async Task ValidateLogonTransactionX_InvalidDeviceId_CorrectResponseRetur .ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier1, CancellationToken.None); + TestData.DeviceIdentifier1, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidDeviceIdentifier); @@ -136,7 +136,7 @@ public async Task ValidateLogonTransactionX_MerchantHasNoDevices_CorrectResponse Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier1, CancellationToken.None); + TestData.DeviceIdentifier1, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.SuccessNeedToAddDevice); @@ -151,7 +151,7 @@ public async Task ValidateReconciliationTransactionX_ValidationSuccessful_Correc .ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.Success); @@ -164,7 +164,7 @@ public async Task ValidateReconciliationTransactionX_InvalidEstate_CorrectRespon .ReturnsAsync(Result.NotFound("Estate Not Found")); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidEstateId); @@ -177,7 +177,7 @@ public async Task ValidateReconciliationTransactionX_FailureWhileGettingEstate_C .ReturnsAsync(Result.Failure("Failed")); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); @@ -192,7 +192,7 @@ public async Task ValidateReconciliationTransactionX_InvalidMerchant_CorrectResp .ReturnsAsync(Result.NotFound("Merchant Not Found")); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidMerchantId); @@ -207,7 +207,7 @@ public async Task ValidateReconciliationTransactionX_FailureWhileGettingMerchant .ReturnsAsync(Result.Failure("Merchant Not Found")); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier, CancellationToken.None); + TestData.DeviceIdentifier, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); @@ -222,7 +222,7 @@ public async Task ValidateReconciliationTransactionX_InvalidDeviceId_CorrectResp .ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier1, CancellationToken.None); + TestData.DeviceIdentifier1, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidDeviceIdentifier); @@ -237,7 +237,7 @@ public async Task ValidateReconciliationTransactionX_MerchantHasNoDevices_Correc .ReturnsAsync(TestData.Aggregates.CreatedMerchantAggregate()); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, - TestData.DeviceIdentifier1, CancellationToken.None); + TestData.DeviceIdentifier1, TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.NoValidDevices); @@ -260,7 +260,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_DeviceNot TestData.DeviceIdentifier1, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidDeviceIdentifier); @@ -281,7 +281,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.NoEstateOperators); @@ -302,7 +302,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.OperatorNotEnabledForEstate); @@ -323,7 +323,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.NoEstateOperators); @@ -344,7 +344,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou TestData.DeviceIdentifier, TestData.OperatorId2, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.OperatorNotValidForEstate); @@ -365,7 +365,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateNot TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidEstateId); @@ -386,7 +386,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_GetEstate TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); @@ -412,7 +412,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidCo TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidContractIdValue); @@ -437,7 +437,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidPr TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidProductIdValue); @@ -461,7 +461,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidTr TestData.DeviceIdentifier, TestData.OperatorId, transactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidSaleTransactionAmount); @@ -484,7 +484,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantD TestData.DeviceIdentifier1, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.NoValidDevices); @@ -509,7 +509,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantD TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.ContractNotValidForMerchant); @@ -536,7 +536,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantH TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.MerchantHasNoContractsConfigured); @@ -560,7 +560,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.MerchantDoesNotHaveEnoughCredit); @@ -584,7 +584,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidMerchantId); @@ -607,7 +607,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_FailedGet TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); @@ -635,7 +635,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.InvalidMerchantId); @@ -662,7 +662,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_FailedGet TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); @@ -686,7 +686,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantO TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.NoMerchantOperators); @@ -709,7 +709,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantO TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.OperatorNotEnabledForMerchant); @@ -732,7 +732,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_OperatorN TestData.DeviceIdentifier, TestData.OperatorId2, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.OperatorNotValidForMerchant); } @@ -757,7 +757,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_ProductId TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.ProductNotValidForMerchant); @@ -782,7 +782,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_Successfu TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.Success); } @@ -807,10 +807,11 @@ public async Task TransactionValidationService_ValidateSaleTransaction_FailedGet TestData.DeviceIdentifier, TestData.OperatorId, TestData.TransactionAmount, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); result.Data.ResponseCode.ShouldBe(TransactionResponseCode.UnknownFailure); } } + diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs index 7c59d143..6145f5c4 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs @@ -1,4 +1,4 @@ -using SimpleResults; +using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.Database.Contexts; using TransactionProcessor.Models; @@ -60,7 +60,7 @@ public async Task VoucherDomainService_IssueVoucher_EstateWithNoOperators_ErrorT this.AggregateService.Setup(v => v.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new VoucherAggregate())); this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.Aggregates.CreatedEstateAggregate()); var result = await this.VoucherDomainService.IssueVoucher(TestData.IssueVoucherCommand, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -97,7 +97,7 @@ public async Task VoucherDomainService_IssueVoucher_EstateWithNoOperators_ErrorT // TestData.Value, // TestData.RecipientEmail, // TestData.RecipientMobile, - // CancellationToken.None); + // TestContext.Current.CancellationToken); // result.IsFailed.ShouldBeTrue(); //} @@ -108,7 +108,7 @@ public async Task VoucherDomainService_IssueVoucher_InvalidEstate_ErrorThrown() this.AggregateService.Setup(f => f.Get(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.Aggregates.EmptyEstateAggregate); Result result = await this.VoucherDomainService.IssueVoucher(TestData.IssueVoucherCommand, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -118,7 +118,7 @@ public async Task VoucherDomainService_IssueVoucher_OperatorNotSupportedByEstate 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); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -130,7 +130,7 @@ public async Task VoucherDomainService_IssueVoucher_VoucherIssued() { 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); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -149,12 +149,12 @@ public async Task VoucherDomainService_RedeemVoucher_InvalidEstate_ErrorThrown() Barcode = TestData.Barcode, Timestamp = BitConverter.GetBytes(DateTime.UtcNow.Ticks) }); - await this.Context.SaveChangesAsync(); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); Result result = await this.VoucherDomainService.RedeemVoucher(TestData.EstateId, TestData.VoucherCode, TestData.RedeemedDateTime, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -173,12 +173,12 @@ public async Task VoucherDomainService_RedeemVoucher_VoucherRedeemed() { Barcode = TestData.Barcode, Timestamp = BitConverter.GetBytes(DateTime.UtcNow.Ticks) }); - await this.Context.SaveChangesAsync(); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); Result result = await this.VoucherDomainService.RedeemVoucher(TestData.EstateId, TestData.VoucherCode, TestData.RedeemedDateTime, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); @@ -193,7 +193,7 @@ public async Task VoucherDomainService_RedeemVoucher_VoucherNotFound_ErrorThrown Result result = await this.VoucherDomainService.RedeemVoucher(TestData.EstateId, TestData.VoucherCode, TestData.RedeemedDateTime, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -203,7 +203,7 @@ public async Task VoucherDomainService_IssueVoucher_GetVoucherFailed_ErrorThrown 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); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -214,7 +214,7 @@ public async Task VoucherDomainService_IssueVoucher_SaveFailed_ErrorThrown() { 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); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -229,12 +229,12 @@ public async Task VoucherDomainService_RedeemVoucher_GetVoucherAggregateFailed_E Barcode = TestData.Barcode, Timestamp = BitConverter.GetBytes(DateTime.UtcNow.Ticks) }); - await this.Context.SaveChangesAsync(); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); Result result = await this.VoucherDomainService.RedeemVoucher(TestData.EstateId, TestData.VoucherCode, TestData.RedeemedDateTime, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -251,12 +251,12 @@ public async Task VoucherDomainService_RedeemVoucher_SaveFailed_ErrorThrown() { Barcode = TestData.Barcode, Timestamp = BitConverter.GetBytes(DateTime.UtcNow.Ticks) }); - await this.Context.SaveChangesAsync(); + await this.Context.SaveChangesAsync(TestContext.Current.CancellationToken); Result result = await this.VoucherDomainService.RedeemVoucher(TestData.EstateId, TestData.VoucherCode, TestData.RedeemedDateTime, - CancellationToken.None); + TestContext.Current.CancellationToken); result.IsFailed.ShouldBeTrue(); } @@ -269,4 +269,4 @@ private EstateManagementContext GetContext(String databaseName) #endregion } -} \ No newline at end of file +} diff --git a/TransactionProcessor.BusinessLogic/EventHandling/ReadModelDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/ReadModelDomainEventHandler.cs index 73e9c791..6cd7906f 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/ReadModelDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/ReadModelDomainEventHandler.cs @@ -176,6 +176,7 @@ private Task HandleStatementDomainEvent(IDomainEvent domainEvent, private Task HandleFloatDomainEvent(IDomainEvent domainEvent, CancellationToken cancellationToken) => domainEvent switch { + FloatCreatedEvent de => this.EstateReportingRepository.CreateFloat(de, cancellationToken), FloatCreatedForContractProductEvent de => this.EstateReportingRepository.CreateFloat(de, cancellationToken), FloatCreditPurchasedEvent de => this.EstateReportingRepository.CreateFloatActivity(de, cancellationToken), FloatDecreasedByTransactionEvent de => this.EstateReportingRepository.CreateFloatActivity(de, cancellationToken), diff --git a/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs b/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs index 1fbbc805..5e9efb07 100644 --- a/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs +++ b/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs @@ -8,7 +8,7 @@ namespace TransactionProcessor.BusinessLogic.RequestHandlers using Requests; using TransactionProcessor.BusinessLogic.Services; - public class FloatRequestHandler :IRequestHandler, + public class FloatRequestHandler :IRequestHandler, IRequestHandler, IRequestHandler, IRequestHandler @@ -21,8 +21,8 @@ public FloatRequestHandler(IFloatDomainService floatDomainService){ - public async Task Handle(FloatCommands.CreateFloatForContractProductCommand command, CancellationToken cancellationToken){ - return await this.FloatDomainService.CreateFloatForContractProduct(command, cancellationToken); + public async Task Handle(FloatCommands.CreateFloatCommand command, CancellationToken cancellationToken){ + return await this.FloatDomainService.CreateFloat(command, cancellationToken); } public async Task Handle(FloatCommands.RecordCreditPurchaseForFloatCommand command, CancellationToken cancellationToken){ diff --git a/TransactionProcessor.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs b/TransactionProcessor.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs index 9212dda8..d0531471 100644 --- a/TransactionProcessor.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs +++ b/TransactionProcessor.BusinessLogic/RequestHandlers/TransactionRequestHandler.cs @@ -16,30 +16,13 @@ public class TransactionRequestHandler : IRequestHandler, IRequestHandler, IRequestHandler { - #region Fields - - /// - /// The transaction domain service - /// private readonly ITransactionDomainService TransactionDomainService; - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The transaction domain service. public TransactionRequestHandler(ITransactionDomainService transactionDomainService) { this.TransactionDomainService = transactionDomainService; } - #endregion - - #region Methods - public async Task> Handle(TransactionCommands.ProcessLogonTransactionCommand command, CancellationToken cancellationToken) { return await this.TransactionDomainService.ProcessLogonTransaction( @@ -58,8 +41,6 @@ public async Task> Handle(Trans return await this.TransactionDomainService.ProcessReconciliationTransaction(command, cancellationToken); } - #endregion - public async Task Handle(TransactionCommands.ResendTransactionReceiptCommand command, CancellationToken cancellationToken) { return await this.TransactionDomainService.ResendTransactionReceipt(command, cancellationToken); diff --git a/TransactionProcessor.BusinessLogic/Requests/FloatCommands.cs b/TransactionProcessor.BusinessLogic/Requests/FloatCommands.cs index 8e165143..f5a026b8 100644 --- a/TransactionProcessor.BusinessLogic/Requests/FloatCommands.cs +++ b/TransactionProcessor.BusinessLogic/Requests/FloatCommands.cs @@ -7,10 +7,9 @@ namespace TransactionProcessor.BusinessLogic.Requests; [ExcludeFromCodeCoverage] public record FloatCommands { - public record CreateFloatForContractProductCommand(Guid EstateId, - Guid ContractId, - Guid ProductId, - DateTime CreateDateTime) : IRequest; + public record CreateFloatCommand(Guid EstateId, + Guid FloatId, + DateTime CreateDateTime) : IRequest; public record RecordCreditPurchaseForFloatCommand(Guid EstateId, Guid FloatId, diff --git a/TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs b/TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs index 2bdcb175..be1b50aa 100644 --- a/TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs @@ -15,7 +15,7 @@ namespace TransactionProcessor.BusinessLogic.Services using TransactionProcessor.Aggregates; public interface IFloatDomainService { - Task CreateFloatForContractProduct(FloatCommands.CreateFloatForContractProductCommand command, + Task CreateFloat(FloatCommands.CreateFloatCommand command, CancellationToken cancellationToken); Task RecordCreditPurchase(FloatCommands.RecordCreditPurchaseForFloatCommand command, @@ -49,48 +49,47 @@ private async Task ValidateEstate(Guid estateId, CancellationToken cance return Result.Success(); } - private async Task ValidateContractProduct(Guid estateId, Guid contractId, Guid productId, CancellationToken cancellationToken) + private async Task> GetEstateAggregate(Guid estateId, CancellationToken cancellationToken) { - Result getContractResult = await DomainServiceHelper.GetAggregateOrFailure( - (token) => this.AggregateService.Get(contractId, token), - contractId, + return await DomainServiceHelper.GetAggregateOrFailure( + token => this.AggregateService.Get(estateId, token), + estateId, cancellationToken, isNotFoundError: true); + } - ContractAggregate contractAggregate = getContractResult.Data; - Models.Contract.Contract contract = contractAggregate.GetContract(); - Boolean productExists = contract.Products.Any(cp => cp.ContractProductId == productId); + private static Result ValidateOperator(EstateAggregate estateAggregate, Guid operatorId) + { + TransactionProcessor.Models.Estate.Estate estate = estateAggregate.GetEstate(); + Boolean operatorExists = estate.Operators.Any(o => o.OperatorId == operatorId && o.IsDeleted == false); + if (operatorExists == false) { + return Result.Invalid($"Operator with Id {operatorId} is not supported on Estate [{estate.Name}]"); + } - return productExists switch { - false => Result.NotFound($"Contract Product with Id {productId} not found in Contract Id {contractId} for Estate Id {estateId}"), - _ => Result.Success() - }; + return Result.Success(); } - public async Task CreateFloatForContractProduct(FloatCommands.CreateFloatForContractProductCommand command, + public async Task CreateFloat(FloatCommands.CreateFloatCommand command, CancellationToken cancellationToken){ try { - Result validateEstateResult = await this.ValidateEstate(command.EstateId, cancellationToken); - if (validateEstateResult.IsFailed) { - return ResultHelpers.CreateFailure(validateEstateResult); + Result getEstateResult = await this.GetEstateAggregate(command.EstateId, cancellationToken); + if (getEstateResult.IsFailed) { + return ResultHelpers.CreateFailure(getEstateResult); } - Result validateProductResult = await this.ValidateContractProduct(command.EstateId, command.ContractId, command.ProductId, cancellationToken); - if (validateProductResult.IsFailed) { - return ResultHelpers.CreateFailure(validateProductResult); + Result validateOperatorResult = ValidateOperator(getEstateResult.Data, command.FloatId); + if (validateOperatorResult.IsFailed) { + return ResultHelpers.CreateFailure(validateOperatorResult); } - - // Generate the float id - Guid floatId = IdGenerationService.GenerateFloatAggregateId(command.EstateId, command.ContractId, command.ProductId); - - Result getFloatResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest(floatId, ct), floatId, cancellationToken, false); + + Result getFloatResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest(command.FloatId, ct), command.FloatId, cancellationToken, false); if (getFloatResult.IsFailed) return ResultHelpers.CreateFailure(getFloatResult); FloatAggregate floatAggregate = getFloatResult.Data; - Result stateResult = floatAggregate.CreateFloat(command.EstateId, command.ContractId, command.ProductId, command.CreateDateTime); + Result stateResult = floatAggregate.CreateFloat(command.EstateId, command.CreateDateTime); if (stateResult.IsFailed) return ResultHelpers.CreateFailure(stateResult); @@ -164,7 +163,7 @@ public async Task RecordTransaction(FloatActivityCommands.RecordTransact if (getTransactionResult.IsFailed) return ResultHelpers.CreateFailure(getTransactionResult); - Guid floatId = IdGenerationService.GenerateFloatAggregateId(command.EstateId, getTransactionResult.Data.ContractId, getTransactionResult.Data.ProductId); + Guid floatId = getTransactionResult.Data.OperatorId; // Generate the id for the activity aggregate Guid floatActivityAggregateId = IdGenerationService.GenerateFloatActivityAggregateId(command.EstateId, floatId, getTransactionResult.Data.TransactionDateTime.Date); diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs index 0a3c1073..856cc40b 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs @@ -625,7 +625,7 @@ private async Task> ValidateTransaction(Tran private async Task<(decimal UnitCost, decimal TotalCost)> GetFloatCost(TransactionCommands.ProcessSaleTransactionCommand command, CancellationToken cancellationToken) { - Guid floatAggregateId = IdGenerationService.GenerateFloatAggregateId(command.EstateId, command.ContractId, command.ProductId); + Guid floatAggregateId = command.OperatorId; Logger.LogDebug($"Fetching FloatAggregate {floatAggregateId}"); diff --git a/TransactionProcessor.Client/ITransactionProcessorClient.cs b/TransactionProcessor.Client/ITransactionProcessorClient.cs index f745a247..b1c7f6bf 100644 --- a/TransactionProcessor.Client/ITransactionProcessorClient.cs +++ b/TransactionProcessor.Client/ITransactionProcessorClient.cs @@ -78,9 +78,9 @@ Task RedeemVoucher(String accessToken, RedeemVoucherRequest redeemVoucherRequest, CancellationToken cancellationToken); - Task CreateFloatForContractProduct(String accessToken, - Guid estateId, - CreateFloatForContractProductRequest createFloatForContractProductRequest, + Task CreateFloat(String accessToken, + Guid estateId, + CreateFloatRequest createFloatForContractProductRequest, CancellationToken cancellationToken); Task UpdateMerchantOpeningHours(String accessToken, diff --git a/TransactionProcessor.Client/TransactionProcessorClient.cs b/TransactionProcessor.Client/TransactionProcessorClient.cs index e498f5f8..44a36a4c 100644 --- a/TransactionProcessor.Client/TransactionProcessorClient.cs +++ b/TransactionProcessor.Client/TransactionProcessorClient.cs @@ -103,14 +103,14 @@ public async Task>> GetEstates(String accessToken, } } - public async Task CreateFloatForContractProduct(String accessToken, + public async Task CreateFloat(String accessToken, Guid estateId, - CreateFloatForContractProductRequest createFloatForContractProductRequest, + CreateFloatRequest createFloatForContractProductRequest, CancellationToken cancellationToken) { String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/floats"); try { - var result = await this.Post(requestUri, createFloatForContractProductRequest, accessToken, cancellationToken); + var result = await this.Post(requestUri, createFloatForContractProductRequest, accessToken, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); @@ -119,7 +119,7 @@ public async Task CreateFloatForContractProduct(String accessToken, } catch (Exception ex) { // An exception has occurred, add some additional information to the message - Exception exception = new("Error creating contract product float.", ex); + Exception exception = new("Error creating float.", ex); throw exception; } diff --git a/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs b/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs index 2c158d42..01e326d2 100644 --- a/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs +++ b/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs @@ -2,20 +2,13 @@ namespace TransactionProcessor.DataTransferObjects{ - public class CreateFloatForContractProductRequest{ + public class CreateFloatRequest{ - public Guid ContractId{ get; set; } - - public Guid ProductId{ get; set; } + public Guid FloatId { get; set; } public DateTime CreateDateTime{ get; set; } } - - public class CreateFloatForContractProductResponse - { - public Guid FloatId { get; set; } - } - + public class RecordFloatCreditPurchaseRequest{ public Guid FloatId { get; set; } diff --git a/TransactionProcessor.Database/Entities/Float.cs b/TransactionProcessor.Database/Entities/Float.cs index 10f205dc..4262316c 100644 --- a/TransactionProcessor.Database/Entities/Float.cs +++ b/TransactionProcessor.Database/Entities/Float.cs @@ -5,11 +5,7 @@ public class Float public Guid FloatId { get; set; } public Guid EstateId { get; set; } - - public Guid ContractId { get; set; } - - public Guid ProductId { get; set; } - + public DateTime CreatedDateTime { get; set; } public DateTime CreatedDate { get; set; } } diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20260827212220_remove_columns_from_float_table.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20260827212220_remove_columns_from_float_table.Designer.cs new file mode 100644 index 00000000..76809c96 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20260827212220_remove_columns_from_float_table.Designer.cs @@ -0,0 +1,1704 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TransactionProcessor.Database.Contexts; + +#nullable disable + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementContext))] + [Migration("20260827212220_remove_columns_from_float_table")] + partial class remove_columns_from_float_table + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.ContractProduct", b => + { + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractProductReportingId"); + + b.HasIndex("ContractProductId", "ContractId") + .IsUnique(); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductTransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductTransactionFeeReportingId")); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductTransactionFeeReportingId"); + + b.HasIndex("ContractProductTransactionFeeId", "ContractProductId") + .IsUnique(); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.EstateOperator", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("EstateId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.FileFormatHandler", b => + { + b.Property("FileFormatHandlerId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("FileFormatHandlerId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("FileFormatHandlers"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogReportingId"); + + b.HasIndex("EstateId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.FileLine", b => + { + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileId", "LineNumber")); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.FileProfileConfiguration", b => + { + b.Property("FileProfileId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("FileFormatHandlerId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineTerminator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ListeningDirectory") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequestTypeId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileProfileId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("FileProfileConfigurations"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Merchant", b => + { + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId"); + + b.HasIndex("EstateId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantContact", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantContract", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantId", "ContractId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.HasKey("MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantOpeningHours", b => + { + b.Property("MerchantId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("FridayClosing") + .HasColumnType("nvarchar(max)"); + + b.Property("FridayOpening") + .HasColumnType("nvarchar(max)"); + + b.Property("MondayClosing") + .HasColumnType("nvarchar(max)"); + + b.Property("MondayOpening") + .HasColumnType("nvarchar(max)"); + + b.Property("SaturdayClosing") + .HasColumnType("nvarchar(max)"); + + b.Property("SaturdayOpening") + .HasColumnType("nvarchar(max)"); + + b.Property("SundayClosing") + .HasColumnType("nvarchar(max)"); + + b.Property("SundayOpening") + .HasColumnType("nvarchar(max)"); + + b.Property("ThursdayClosing") + .HasColumnType("nvarchar(max)"); + + b.Property("ThursdayOpening") + .HasColumnType("nvarchar(max)"); + + b.Property("TuesdayClosing") + .HasColumnType("nvarchar(max)"); + + b.Property("TuesdayOpening") + .HasColumnType("nvarchar(max)"); + + b.Property("WednesdayClosing") + .HasColumnType("nvarchar(max)"); + + b.Property("WednesdayOpening") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId"); + + b.ToTable("merchantopeninghours"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantSchedule", b => + { + b.Property("MerchantScheduleId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("MerchantScheduleId"); + + b.HasIndex("MerchantId", "Year") + .IsUnique(); + + b.ToTable("merchantschedule"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantScheduleMonth", b => + { + b.Property("MerchantScheduleId") + .HasColumnType("uniqueidentifier"); + + b.Property("Month") + .HasColumnType("int"); + + b.Property("ClosedDays") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantScheduleId", "Month"); + + b.ToTable("merchantschedulemonth"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementId", "TransactionId", "ContractProductTransactionFeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId", "MerchantId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.RequestType", b => + { + b.Property("RequestTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("RequestTypeId"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("RequestTypes"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("EstateId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateId", "SettlementId"), false); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.StatementHeader", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantId", "StatementId"), false); + + b.HasIndex("StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Summary.SettlementSummary", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("FeeCount") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("SalesCount") + .HasColumnType("int"); + + b.Property("SalesValue") + .HasColumnType("decimal(18,2)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("SettlementDate", "MerchantReportingId", "OperatorReportingId", "ContractProductReportingId", "IsCompleted", "IsSettled") + .IsUnique(); + + b.ToTable("SettlementSummary"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Summary.TodayTransaction", b => + { + b.Property("AuthorisationCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Hour") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + b.ToTable("TodayTransactions"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Summary.TransactionHistory", b => + { + b.Property("AuthorisationCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Hour") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + b.ToTable("TransactionHistory"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.TransactionTimings", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorCommunicationsCompletedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorCommunicationsDurationInMilliseconds") + .HasColumnType("float"); + + b.Property("OperatorCommunicationsStartedDateTime") + .HasColumnType("datetime2"); + + b.Property("TotalTransactionInMilliseconds") + .HasColumnType("float"); + + b.Property("TransactionCompletedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionProcessingDurationInMilliseconds") + .HasColumnType("float"); + + b.Property("TransactionStartedDateTime") + .HasColumnType("datetime2"); + + b.HasKey("TransactionId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionId"), false); + + b.ToTable("transactiontimings"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.Entities.VoucherProjectionState", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Barcode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("Timestamp") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucherprojectionstate"); + }); + + modelBuilder.Entity("TransactionProcessor.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); + + modelBuilder.Entity("TransactionProcessor.ProjectionEngine.Database.Database.Entities.Event", b => + { + b.Property("EventId") + .HasColumnType("uniqueidentifier"); + + b.Property("Type") + .HasColumnType("nvarchar(450)"); + + b.Property("Date") + .HasColumnType("date"); + + b.HasKey("EventId", "Type"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId", "Type")); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("TransactionProcessor.ProjectionEngine.Database.Database.Entities.MerchantBalanceChangedEntry", b => + { + b.Property("AggregateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalEventId") + .HasColumnType("uniqueidentifier"); + + b.Property("CauseOfChangeId") + .HasColumnType("uniqueidentifier"); + + b.Property("ChangeAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("DebitOrCredit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Reference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("AggregateId", "OriginalEventId"); + + b.ToTable("MerchantBalanceChangedEntry"); + }); + + modelBuilder.Entity("TransactionProcessor.ProjectionEngine.Database.Database.Entities.MerchantBalanceProjectionState", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorisedSales") + .HasColumnType("decimal(18,2)"); + + b.Property("AvailableBalance") + .HasColumnType("decimal(18,2)"); + + b.Property("Balance") + .HasColumnType("decimal(18,2)"); + + b.Property("CompletedTransactionCount") + .HasColumnType("int"); + + b.Property("DeclinedSales") + .HasColumnType("decimal(18,2)"); + + b.Property("DepositCount") + .HasColumnType("int"); + + b.Property("FeeCount") + .HasColumnType("int"); + + b.Property("LastDeposit") + .HasColumnType("datetime2"); + + b.Property("LastFee") + .HasColumnType("datetime2"); + + b.Property("LastSale") + .HasColumnType("datetime2"); + + b.Property("LastWithdrawal") + .HasColumnType("datetime2"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SaleCount") + .HasColumnType("int"); + + b.Property("StartedTransactionCount") + .HasColumnType("int"); + + b.Property("Timestamp") + .IsConcurrencyToken() + .IsRequired() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + + b.Property("TotalDeposited") + .HasColumnType("decimal(18,2)"); + + b.Property("TotalWithdrawn") + .HasColumnType("decimal(18,2)"); + + b.Property("ValueOfFees") + .HasColumnType("decimal(18,2)"); + + b.Property("WithdrawalCount") + .HasColumnType("int"); + + b.HasKey("EstateId", "MerchantId"); + + b.ToTable("MerchantBalanceProjectionState"); + }); + + modelBuilder.Entity("TransactionProcessor.ProjectionEngine.Database.Database.ViewEntities.MerchantBalanceHistoryViewEntry", b => + { + b.Property("Balance") + .HasColumnType("decimal(18,2)"); + + b.Property("ChangeAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("DebitOrCredit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EntryDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalEventId") + .HasColumnType("uniqueidentifier"); + + b.Property("Reference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.ToTable((string)null); + + b.ToView("uvwMerchantBalanceHistory", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20260827212220_remove_columns_from_float_table.cs b/TransactionProcessor.Database/Migrations/SqlServer/20260827212220_remove_columns_from_float_table.cs new file mode 100644 index 00000000..28c68028 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20260827212220_remove_columns_from_float_table.cs @@ -0,0 +1,41 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class remove_columns_from_float_table : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ContractId", + table: "Floats"); + + migrationBuilder.DropColumn( + name: "ProductId", + table: "Floats"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ContractId", + table: "Floats", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ProductId", + table: "Floats", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs b/TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs index 79fbcbe7..81042d8d 100644 --- a/TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs +++ b/TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "10.0.8") + .HasAnnotation("ProductVersion", "10.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -429,9 +429,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); - b.Property("ContractId") - .HasColumnType("uniqueidentifier"); - b.Property("CreatedDate") .HasColumnType("date"); @@ -441,9 +438,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("EstateId") .HasColumnType("uniqueidentifier"); - b.Property("ProductId") - .HasColumnType("uniqueidentifier"); - b.HasKey("FloatId"); SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); diff --git a/TransactionProcessor.DatabaseTests/BaseTest.cs b/TransactionProcessor.DatabaseTests/BaseTest.cs index d4ae060a..8a6653fe 100644 --- a/TransactionProcessor.DatabaseTests/BaseTest.cs +++ b/TransactionProcessor.DatabaseTests/BaseTest.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using DotNet.Testcontainers.Builders; using DotNet.Testcontainers.Networks; using Microsoft.Extensions.DependencyInjection; @@ -28,7 +28,7 @@ public virtual async ValueTask InitializeAsync() await this.StartSqlContainer(); await this.GetRepository(); EstateManagementContext context = this.GetContext(); - await context.Database.EnsureCreatedAsync(CancellationToken.None); + await context.Database.EnsureCreatedAsync(TestContext.Current.CancellationToken); } public EstateManagementContext GetContext() @@ -116,3 +116,4 @@ public override async Task CreateSubscriptions() } } + diff --git a/TransactionProcessor.DatabaseTests/ContractEventTests.cs b/TransactionProcessor.DatabaseTests/ContractEventTests.cs index 9f469fa4..6bd1297c 100644 --- a/TransactionProcessor.DatabaseTests/ContractEventTests.cs +++ b/TransactionProcessor.DatabaseTests/ContractEventTests.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Moq; @@ -18,17 +18,17 @@ public class ReconciliationEventTests : BaseTest [Fact] public async Task AddReconciliation_ReconciliationIsAdded() { - Result result = await this.Repository.StartReconciliation(TestData.DomainEvents.ReconciliationHasStartedEvent, CancellationToken.None); + Result result = await this.Repository.StartReconciliation(TestData.DomainEvents.ReconciliationHasStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Reconciliation? reconciliation = await context.Reconciliations.SingleOrDefaultAsync(c => c.TransactionId == TestData.DomainEvents.ReconciliationHasStartedEvent.TransactionId); + Reconciliation? reconciliation = await context.Reconciliations.SingleOrDefaultAsync(c => c.TransactionId == TestData.DomainEvents.ReconciliationHasStartedEvent.TransactionId, TestContext.Current.CancellationToken); reconciliation.ShouldNotBeNull(); } [Fact] public async Task AddReconciliation_EventReplayHandled() { - Result result = await this.Repository.StartReconciliation(TestData.DomainEvents.ReconciliationHasStartedEvent, CancellationToken.None); + Result result = await this.Repository.StartReconciliation(TestData.DomainEvents.ReconciliationHasStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.StartReconciliation(TestData.DomainEvents.ReconciliationHasStartedEvent, CancellationToken.None); + result = await this.Repository.StartReconciliation(TestData.DomainEvents.ReconciliationHasStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } @@ -38,33 +38,33 @@ public class ContractEventTests : BaseTest [Fact] public async Task AddContract_ContractIsAdded() { - Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Contract? contract = await context.Contracts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.ContractCreatedEvent.ContractId); + Contract? contract = await context.Contracts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.ContractCreatedEvent.ContractId, TestContext.Current.CancellationToken); contract.ShouldNotBeNull(); } [Fact] public async Task AddContract_EventReplayHandled() { - Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None); + result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task AddContractToMerchant_ContractIsAddedToMerchant() { - Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddContractToMerchant(TestData.DomainEvents.ContractAddedToMerchantEvent, CancellationToken.None); + result = await this.Repository.AddContractToMerchant(TestData.DomainEvents.ContractAddedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantContract? merchantContract = await context.MerchantContracts.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.ContractAddedToMerchantEvent.MerchantId && c.ContractId == TestData.DomainEvents.ContractAddedToMerchantEvent.ContractId); + MerchantContract? merchantContract = await context.MerchantContracts.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.ContractAddedToMerchantEvent.MerchantId && c.ContractId == TestData.DomainEvents.ContractAddedToMerchantEvent.ContractId, TestContext.Current.CancellationToken); merchantContract.ShouldNotBeNull(); merchantContract.IsDeleted.ShouldBeFalse(); } @@ -72,16 +72,16 @@ public async Task AddContractToMerchant_ContractIsAddedToMerchant() [Fact] public async Task RemoveContractFromMerchant_ContractIsMarkedDeleted() { - Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddContractToMerchant(TestData.DomainEvents.ContractAddedToMerchantEvent, CancellationToken.None); + result = await this.Repository.AddContractToMerchant(TestData.DomainEvents.ContractAddedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.RemoveContractFromMerchant(TestData.DomainEvents.ContractRemovedFromMerchantEvent, CancellationToken.None); + result = await this.Repository.RemoveContractFromMerchant(TestData.DomainEvents.ContractRemovedFromMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantContract? merchantContract = await context.MerchantContracts.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.ContractRemovedFromMerchantEvent.MerchantId && c.ContractId == TestData.DomainEvents.ContractRemovedFromMerchantEvent.ContractId); + MerchantContract? merchantContract = await context.MerchantContracts.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.ContractRemovedFromMerchantEvent.MerchantId && c.ContractId == TestData.DomainEvents.ContractRemovedFromMerchantEvent.ContractId, TestContext.Current.CancellationToken); merchantContract.ShouldNotBeNull(); merchantContract.IsDeleted.ShouldBeTrue(); } @@ -89,18 +89,18 @@ public async Task RemoveContractFromMerchant_ContractIsMarkedDeleted() [Fact] public async Task DisableContractProductTransactionFee_TransactionFeeIsDisabled() { - Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue("Add"); - result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, CancellationToken.None); + result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue("Product Add"); - result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, CancellationToken.None); + result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue("Fee Add"); - result = await this.Repository.DisableContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductDisabledEvent, CancellationToken.None); + result = await this.Repository.DisableContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductDisabledEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(result.Message); EstateManagementContext context = this.GetContext(); - ContractProductTransactionFee? contractProductTransactionFee = await context.ContractProductTransactionFees.SingleOrDefaultAsync(c => c.ContractProductTransactionFeeId == TestData.DomainEvents.TransactionFeeForProductDisabledEvent.TransactionFeeId); + ContractProductTransactionFee? contractProductTransactionFee = await context.ContractProductTransactionFees.SingleOrDefaultAsync(c => c.ContractProductTransactionFeeId == TestData.DomainEvents.TransactionFeeForProductDisabledEvent.TransactionFeeId, TestContext.Current.CancellationToken); contractProductTransactionFee.ShouldNotBeNull(); contractProductTransactionFee.IsEnabled.ShouldBeFalse(); } @@ -108,59 +108,61 @@ public async Task DisableContractProductTransactionFee_TransactionFeeIsDisabled( [Fact] public async Task AddContractProduct_ContractProductIsAdded() { - Result result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, CancellationToken.None); + Result result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - ContractProduct? fixedContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ProductId); + ContractProduct? fixedContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ProductId, TestContext.Current.CancellationToken); fixedContractProduct.ShouldNotBeNull(); - result = await this.Repository.AddContractProduct(TestData.DomainEvents.VariableValueProductAddedToContractEvent, CancellationToken.None); + result = await this.Repository.AddContractProduct(TestData.DomainEvents.VariableValueProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); context = this.GetContext(); - ContractProduct? variableContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ProductId); + ContractProduct? variableContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ProductId, TestContext.Current.CancellationToken); variableContractProduct.ShouldNotBeNull(); } [Fact] public async Task AddContractProduct_EventReplayHandled() { - Result result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, CancellationToken.None); + Result result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - ContractProduct? fixedContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ProductId); + ContractProduct? fixedContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.FixedValueProductAddedToContractEvent.ProductId, TestContext.Current.CancellationToken); fixedContractProduct.ShouldNotBeNull(); - result = await this.Repository.AddContractProduct(TestData.DomainEvents.VariableValueProductAddedToContractEvent, CancellationToken.None); + result = await this.Repository.AddContractProduct(TestData.DomainEvents.VariableValueProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); context = this.GetContext(); - ContractProduct? variableContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ProductId); + ContractProduct? variableContractProduct = await context.ContractProducts.SingleOrDefaultAsync(c => c.ContractId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ContractId && c.ContractProductId == TestData.DomainEvents.VariableValueProductAddedToContractEvent.ProductId, TestContext.Current.CancellationToken); variableContractProduct.ShouldNotBeNull(); - result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, CancellationToken.None); + result = await this.Repository.AddContractProduct(TestData.DomainEvents.FixedValueProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddContractProduct(TestData.DomainEvents.VariableValueProductAddedToContractEvent, CancellationToken.None); + result = await this.Repository.AddContractProduct(TestData.DomainEvents.VariableValueProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task AddContractProductTransactionFee_ContractIsAdded() { - Result result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, CancellationToken.None); + Result result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); ContractProductTransactionFee? contractProductTransactionFee = await context.ContractProductTransactionFees.SingleOrDefaultAsync(c => c.ContractProductId == TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent.ProductId && - c.ContractProductTransactionFeeId == TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent.TransactionFeeId); + c.ContractProductTransactionFeeId == TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent.TransactionFeeId, TestContext.Current.CancellationToken); contractProductTransactionFee.ShouldNotBeNull(); } [Fact] public async Task AddContractProductTransactionFee_EventReplayHandled() { - Result result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, CancellationToken.None); + Result result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, CancellationToken.None); + result = await this.Repository.AddContractProductTransactionFee(TestData.DomainEvents.TransactionFeeForProductAddedToContractEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } } + + diff --git a/TransactionProcessor.DatabaseTests/EstateEventTests.cs b/TransactionProcessor.DatabaseTests/EstateEventTests.cs index be211407..184a7892 100644 --- a/TransactionProcessor.DatabaseTests/EstateEventTests.cs +++ b/TransactionProcessor.DatabaseTests/EstateEventTests.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Shared.Logger; using Shouldly; using SimpleResults; @@ -21,7 +21,7 @@ public override async ValueTask InitializeAsync() { [Fact] public async Task CreateReadModel_EstateDatabaseIsMigrated() { - Result result = await this.Repository.CreateReadModel(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None); + Result result = await this.Repository.CreateReadModel(TestData.DomainEvents.EstateCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } } @@ -30,10 +30,10 @@ public class EstateEventTests : BaseTest { [Fact] public async Task AddEstate_EstateIsAdded() { - Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var estate = await context.Estates.SingleOrDefaultAsync(f => f.EstateId == TestData.DomainEvents.EstateCreatedEvent.EstateId); + var estate = await context.Estates.SingleOrDefaultAsync(f => f.EstateId == TestData.DomainEvents.EstateCreatedEvent.EstateId, TestContext.Current.CancellationToken); estate.ShouldNotBeNull(); estate.Name.ShouldBe(TestData.DomainEvents.EstateCreatedEvent.EstateName); } @@ -41,45 +41,47 @@ public async Task AddEstate_EstateIsAdded() [Fact] public async Task AddEstate_EventReplayHandled() { - Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None); + result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task AddEstateSecurityUser_EstateIsAdded() { - Result result = await this.Repository.AddEstateSecurityUser(TestData.DomainEvents.EstateSecurityUserAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddEstateSecurityUser(TestData.DomainEvents.EstateSecurityUserAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var estateSecurityUser = await context.EstateSecurityUsers.SingleOrDefaultAsync(f => f.EstateId == TestData.DomainEvents.EstateSecurityUserAddedEvent.EstateId && f.SecurityUserId == TestData.DomainEvents.EstateSecurityUserAddedEvent.SecurityUserId); + var estateSecurityUser = await context.EstateSecurityUsers.SingleOrDefaultAsync(f => f.EstateId == TestData.DomainEvents.EstateSecurityUserAddedEvent.EstateId && f.SecurityUserId == TestData.DomainEvents.EstateSecurityUserAddedEvent.SecurityUserId, TestContext.Current.CancellationToken); estateSecurityUser.ShouldNotBeNull(); } [Fact] public async Task AddEstateSecurityUser_EventReplayHandled() { - Result result = await this.Repository.AddEstateSecurityUser(TestData.DomainEvents.EstateSecurityUserAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddEstateSecurityUser(TestData.DomainEvents.EstateSecurityUserAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddEstateSecurityUser(TestData.DomainEvents.EstateSecurityUserAddedEvent, CancellationToken.None); + result = await this.Repository.AddEstateSecurityUser(TestData.DomainEvents.EstateSecurityUserAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task UpdateEstate_EstateReferenceIsUpdated() { - Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddEstate(TestData.DomainEvents.EstateCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateEstate(TestData.DomainEvents.EstateReferenceAllocatedEvent, CancellationToken.None); + result = await this.Repository.UpdateEstate(TestData.DomainEvents.EstateReferenceAllocatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var estate = await context.Estates.SingleOrDefaultAsync(f => f.EstateId == TestData.DomainEvents.EstateReferenceAllocatedEvent.EstateId); + var estate = await context.Estates.SingleOrDefaultAsync(f => f.EstateId == TestData.DomainEvents.EstateReferenceAllocatedEvent.EstateId, TestContext.Current.CancellationToken); estate.ShouldNotBeNull(); estate.Reference.ShouldBe(TestData.DomainEvents.EstateReferenceAllocatedEvent.EstateReference); } } + + diff --git a/TransactionProcessor.DatabaseTests/FileImportLogEventTests.cs b/TransactionProcessor.DatabaseTests/FileImportLogEventTests.cs index b23736d0..4ff6ed24 100644 --- a/TransactionProcessor.DatabaseTests/FileImportLogEventTests.cs +++ b/TransactionProcessor.DatabaseTests/FileImportLogEventTests.cs @@ -10,7 +10,7 @@ namespace TransactionProcessor.DatabaseTests; public class FileImportLogEventTests : BaseTest { private async Task CreateFileImportLogAsync() { - Result result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -18,7 +18,7 @@ private async Task CreateFileAsync() { await this.CreateFileImportLogAsync(); - Result result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -26,17 +26,17 @@ private async Task CreateFileLineAsync() { await this.CreateFileAsync(); - Result result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task AddFileImportLog_FileImportLogIsAdded() { - Result result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var fileImportLog = await context.FileImportLogs.SingleOrDefaultAsync(f => f.FileImportLogId == TestData.DomainEvents.ImportLogCreatedEvent.FileImportLogId); + var fileImportLog = await context.FileImportLogs.SingleOrDefaultAsync(f => f.FileImportLogId == TestData.DomainEvents.ImportLogCreatedEvent.FileImportLogId, TestContext.Current.CancellationToken); fileImportLog.ShouldNotBeNull(); fileImportLog.EstateId.ShouldBe(TestData.DomainEvents.ImportLogCreatedEvent.EstateId); fileImportLog.ImportLogDate.ShouldBe(TestData.DomainEvents.ImportLogCreatedEvent.ImportLogDateTime.Date); @@ -45,20 +45,20 @@ public async Task AddFileImportLog_FileImportLogIsAdded() [Fact] public async Task AddFileImportLog_EventReplayHandled() { - Result result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, CancellationToken.None); + result = await this.Repository.AddFileImportLog(TestData.DomainEvents.ImportLogCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task AddFileImportLogFile_FileImportLogIsAdded() { - Result result = await this.Repository.AddFileToImportLog(TestData.DomainEvents.FileAddedToImportLogEvent, CancellationToken.None); + Result result = await this.Repository.AddFileToImportLog(TestData.DomainEvents.FileAddedToImportLogEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var fileImportLogFile = await context.FileImportLogFiles.SingleOrDefaultAsync(f => f.FileImportLogId == TestData.DomainEvents.FileAddedToImportLogEvent.FileImportLogId && f.FileId == TestData.DomainEvents.FileAddedToImportLogEvent.FileId); + var fileImportLogFile = await context.FileImportLogFiles.SingleOrDefaultAsync(f => f.FileImportLogId == TestData.DomainEvents.FileAddedToImportLogEvent.FileImportLogId && f.FileId == TestData.DomainEvents.FileAddedToImportLogEvent.FileId, TestContext.Current.CancellationToken); fileImportLogFile.ShouldNotBeNull(); fileImportLogFile.FilePath.ShouldBe(TestData.DomainEvents.FileAddedToImportLogEvent.FilePath); fileImportLogFile.OriginalFileName.ShouldBe(TestData.DomainEvents.FileAddedToImportLogEvent.OriginalFileName); @@ -67,10 +67,10 @@ public async Task AddFileImportLogFile_FileImportLogIsAdded() [Fact] public async Task AddFileImportLogFile_EventReplayHandled() { - Result result = await this.Repository.AddFileToImportLog(TestData.DomainEvents.FileAddedToImportLogEvent, CancellationToken.None); + Result result = await this.Repository.AddFileToImportLog(TestData.DomainEvents.FileAddedToImportLogEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddFileToImportLog(TestData.DomainEvents.FileAddedToImportLogEvent, CancellationToken.None); + result = await this.Repository.AddFileToImportLog(TestData.DomainEvents.FileAddedToImportLogEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -79,11 +79,11 @@ public async Task AddFile_FileIsAdded() { await this.CreateFileImportLogAsync(); - Result result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - TransactionProcessor.Database.Entities.File? file = await context.Files.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileCreatedEvent.FileId); + TransactionProcessor.Database.Entities.File? file = await context.Files.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileCreatedEvent.FileId, TestContext.Current.CancellationToken); file.ShouldNotBeNull(); file.EstateId.ShouldBe(TestData.DomainEvents.FileCreatedEvent.EstateId); file.MerchantId.ShouldBe(TestData.DomainEvents.FileCreatedEvent.MerchantId); @@ -97,9 +97,9 @@ public async Task AddFile_EventReplayHandled() { await this.CreateFileImportLogAsync(); - Result result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, CancellationToken.None); + result = await this.Repository.AddFile(TestData.DomainEvents.FileCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -108,11 +108,11 @@ public async Task AddFileLineToFile_FileLineIsAdded() { await this.CreateFileAsync(); - Result result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineAddedEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineAddedEvent.LineNumber); + FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineAddedEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineAddedEvent.LineNumber, TestContext.Current.CancellationToken); fileLine.ShouldNotBeNull(); fileLine.FileLineData.ShouldBe(TestData.DomainEvents.FileLineAddedEvent.FileLine); fileLine.Status.ShouldBe("P"); @@ -123,9 +123,9 @@ public async Task AddFileLineToFile_EventReplayHandled() { await this.CreateFileAsync(); - Result result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, CancellationToken.None); + result = await this.Repository.AddFileLineToFile(TestData.DomainEvents.FileLineAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -134,11 +134,11 @@ public async Task UpdateFileAsComplete_FileIsCompleted() { await this.CreateFileAsync(); - Result result = await this.Repository.UpdateFileAsComplete(TestData.DomainEvents.FileProcessingCompletedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateFileAsComplete(TestData.DomainEvents.FileProcessingCompletedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - TransactionProcessor.Database.Entities.File? file = await context.Files.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileProcessingCompletedEvent.FileId); + TransactionProcessor.Database.Entities.File? file = await context.Files.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileProcessingCompletedEvent.FileId, TestContext.Current.CancellationToken); file.ShouldNotBeNull(); file.IsCompleted.ShouldBeTrue(); } @@ -148,11 +148,11 @@ public async Task UpdateFileLineSuccessful_FileLineIsUpdated() { await this.CreateFileLineAsync(); - Result result = await this.Repository.UpdateFileLine(TestData.DomainEvents.FileLineProcessingSuccessfulEvent, CancellationToken.None); + Result result = await this.Repository.UpdateFileLine(TestData.DomainEvents.FileLineProcessingSuccessfulEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineProcessingSuccessfulEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineProcessingSuccessfulEvent.LineNumber); + FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineProcessingSuccessfulEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineProcessingSuccessfulEvent.LineNumber, TestContext.Current.CancellationToken); fileLine.ShouldNotBeNull(); fileLine.Status.ShouldBe("S"); fileLine.TransactionId.ShouldBe(TestData.DomainEvents.FileLineProcessingSuccessfulEvent.TransactionId); @@ -163,11 +163,11 @@ public async Task UpdateFileLineFailed_FileLineIsUpdated() { await this.CreateFileLineAsync(); - Result result = await this.Repository.UpdateFileLine(TestData.DomainEvents.FileLineProcessingFailedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateFileLine(TestData.DomainEvents.FileLineProcessingFailedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineProcessingFailedEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineProcessingFailedEvent.LineNumber); + FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineProcessingFailedEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineProcessingFailedEvent.LineNumber, TestContext.Current.CancellationToken); fileLine.ShouldNotBeNull(); fileLine.Status.ShouldBe("F"); fileLine.TransactionId.ShouldBe(TestData.DomainEvents.FileLineProcessingFailedEvent.TransactionId); @@ -178,13 +178,14 @@ public async Task UpdateFileLineIgnored_FileLineIsUpdated() { await this.CreateFileLineAsync(); - Result result = await this.Repository.UpdateFileLine(TestData.DomainEvents.FileLineProcessingIgnoredEvent, CancellationToken.None); + Result result = await this.Repository.UpdateFileLine(TestData.DomainEvents.FileLineProcessingIgnoredEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineProcessingIgnoredEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineProcessingIgnoredEvent.LineNumber); + FileLine? fileLine = await context.FileLines.SingleOrDefaultAsync(f => f.FileId == TestData.DomainEvents.FileLineProcessingIgnoredEvent.FileId && f.LineNumber == TestData.DomainEvents.FileLineProcessingIgnoredEvent.LineNumber, TestContext.Current.CancellationToken); fileLine.ShouldNotBeNull(); fileLine.Status.ShouldBe("I"); fileLine.TransactionId.ShouldBe(Guid.Empty); } } + diff --git a/TransactionProcessor.DatabaseTests/FloatEventTests.cs b/TransactionProcessor.DatabaseTests/FloatEventTests.cs new file mode 100644 index 00000000..2385579c --- /dev/null +++ b/TransactionProcessor.DatabaseTests/FloatEventTests.cs @@ -0,0 +1,136 @@ +using Microsoft.EntityFrameworkCore; +using Shouldly; +using SimpleResults; +using TransactionProcessor.Database.Contexts; +using TransactionProcessor.Database.Entities; +using TransactionProcessor.DomainEvents; +using TransactionProcessor.Testing; + +namespace TransactionProcessor.DatabaseTests; + +public class FloatEventTests : BaseTest { + [Fact] + public async Task CreateFloat_FloatIsAdded() + { + Result result = await this.Repository.CreateFloat(TestData.DomainEvents.FloatCreatedForContractProductEvent, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + EstateManagementContext context = this.GetContext(); + Float? floatRecord = await context.Floats.SingleOrDefaultAsync(f => f.FloatId == TestData.DomainEvents.FloatCreatedForContractProductEvent.FloatId, TestContext.Current.CancellationToken); + floatRecord.ShouldNotBeNull(); + floatRecord.EstateId.ShouldBe(TestData.DomainEvents.FloatCreatedForContractProductEvent.EstateId); + floatRecord.CreatedDate.ShouldBe(TestData.FloatCreatedDateTime.Date); + floatRecord.CreatedDateTime.ShouldBe(TestData.FloatCreatedDateTime); + } + + [Fact] + public async Task CreateFloat_EventReplayHandled() + { + FloatDomainEvents.FloatCreatedForContractProductEvent @event = TestData.DomainEvents.FloatCreatedForContractProductEvent; + + Result result = await this.Repository.CreateFloat(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + result = await this.Repository.CreateFloat(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + EstateManagementContext context = this.GetContext(); + Int32 floatCount = await context.Floats.CountAsync(f => f.FloatId == @event.FloatId, TestContext.Current.CancellationToken); + floatCount.ShouldBe(1); + } + + [Fact] + public async Task CreateFloatActivity_CreditPurchaseIsAdded() + { + FloatDomainEvents.FloatCreditPurchasedEvent @event = new( + TestData.FloatAggregateId, + TestData.EstateId, + TestData.CreditPurchasedDateTime, + TestData.FloatCreditAmount, + TestData.FloatCreditCostPrice); + + Result result = await this.Repository.CreateFloatActivity(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + EstateManagementContext context = this.GetContext(); + FloatActivity? floatActivity = await context.FloatActivity.SingleOrDefaultAsync(f => f.EventId == @event.EventId, TestContext.Current.CancellationToken); + floatActivity.ShouldNotBeNull(); + floatActivity.FloatId.ShouldBe(@event.FloatId); + floatActivity.ActivityDate.ShouldBe(TestData.CreditPurchasedDateTime.Date); + floatActivity.ActivityDateTime.ShouldBe(TestData.CreditPurchasedDateTime); + floatActivity.Amount.ShouldBe(TestData.FloatCreditAmount); + floatActivity.CostPrice.ShouldBe(TestData.FloatCreditCostPrice); + floatActivity.CreditOrDebit.ShouldBe("C"); + } + + [Fact] + public async Task CreateFloatActivity_CreditPurchaseReplayHandled() + { + FloatDomainEvents.FloatCreditPurchasedEvent @event = new( + TestData.FloatAggregateId, + TestData.EstateId, + TestData.CreditPurchasedDateTime, + TestData.FloatCreditAmount, + TestData.FloatCreditCostPrice); + + Result result = await this.Repository.CreateFloatActivity(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + result = await this.Repository.CreateFloatActivity(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + EstateManagementContext context = this.GetContext(); + Int32 floatActivityCount = await context.FloatActivity.CountAsync(f => f.EventId == @event.EventId, TestContext.Current.CancellationToken); + floatActivityCount.ShouldBe(1); + } + + [Fact] + public async Task CreateFloatActivity_FloatDecreaseIsAdded() + { + await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, TestContext.Current.CancellationToken); + + FloatDomainEvents.FloatDecreasedByTransactionEvent @event = new( + TestData.FloatAggregateId, + TestData.EstateId, + TestData.TransactionId, + TestData.FloatCreditAmount); + + Result result = await this.Repository.CreateFloatActivity(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + EstateManagementContext context = this.GetContext(); + FloatActivity? floatActivity = await context.FloatActivity.SingleOrDefaultAsync(f => f.EventId == @event.EventId, TestContext.Current.CancellationToken); + floatActivity.ShouldNotBeNull(); + floatActivity.FloatId.ShouldBe(@event.FloatId); + floatActivity.ActivityDate.ShouldBe(TestData.TransactionDateTime1.Date); + floatActivity.ActivityDateTime.ShouldBe(TestData.TransactionDateTime1); + floatActivity.Amount.ShouldBe(TestData.FloatCreditAmount); + floatActivity.CostPrice.ShouldBe(0); + floatActivity.CreditOrDebit.ShouldBe("D"); + } + + [Fact] + public async Task CreateFloatActivity_FloatDecreaseReplayHandled() + { + await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, TestContext.Current.CancellationToken); + + FloatDomainEvents.FloatDecreasedByTransactionEvent @event = new( + TestData.FloatAggregateId, + TestData.EstateId, + TestData.TransactionId, + TestData.FloatCreditAmount); + + Result result = await this.Repository.CreateFloatActivity(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + result = await this.Repository.CreateFloatActivity(@event, TestContext.Current.CancellationToken); + result.IsSuccess.ShouldBeTrue(); + + EstateManagementContext context = this.GetContext(); + Int32 floatActivityCount = await context.FloatActivity.CountAsync(f => f.EventId == @event.EventId, TestContext.Current.CancellationToken); + floatActivityCount.ShouldBe(1); + } + +} + + diff --git a/TransactionProcessor.DatabaseTests/MerchantEventTests.cs b/TransactionProcessor.DatabaseTests/MerchantEventTests.cs index 3c4e3a34..14bf4484 100644 --- a/TransactionProcessor.DatabaseTests/MerchantEventTests.cs +++ b/TransactionProcessor.DatabaseTests/MerchantEventTests.cs @@ -11,7 +11,7 @@ namespace TransactionProcessor.DatabaseTests; public class MerchantEventTests : BaseTest { private async Task CreateMerchantAsync() { - Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -23,18 +23,18 @@ private static MerchantDomainEvents.MerchantOpeningHoursUpdatedEvent CreateMerch [Fact] public async Task AddMerchant_MerchantIsAdded() { - Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.MerchantCreatedEvent.MerchantId); + Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.MerchantCreatedEvent.MerchantId, TestContext.Current.CancellationToken); merchant.ShouldNotBeNull(); } [Fact] public async Task AddMerchant_EventReplayHandled() { - Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, CancellationToken.None); + result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -43,11 +43,11 @@ public async Task AddMerchantAddress_MerchantAddressIsAdded() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantAddress? merchantAddress = await context.MerchantAddresses.SingleOrDefaultAsync(c => c.AddressId == TestData.DomainEvents.AddressAddedEvent.AddressId); + MerchantAddress? merchantAddress = await context.MerchantAddresses.SingleOrDefaultAsync(c => c.AddressId == TestData.DomainEvents.AddressAddedEvent.AddressId, TestContext.Current.CancellationToken); merchantAddress.ShouldNotBeNull(); merchantAddress.MerchantId.ShouldBe(TestData.DomainEvents.AddressAddedEvent.MerchantId); merchantAddress.AddressLine1.ShouldBe(TestData.DomainEvents.AddressAddedEvent.AddressLine1); @@ -65,9 +65,9 @@ public async Task AddMerchantAddress_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, CancellationToken.None); + result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -76,11 +76,11 @@ public async Task AddMerchantContact_MerchantContactIsAdded() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantContact? merchantContact = await context.MerchantContacts.SingleOrDefaultAsync(c => c.ContactId == TestData.DomainEvents.ContactAddedEvent.ContactId); + MerchantContact? merchantContact = await context.MerchantContacts.SingleOrDefaultAsync(c => c.ContactId == TestData.DomainEvents.ContactAddedEvent.ContactId, TestContext.Current.CancellationToken); merchantContact.ShouldNotBeNull(); merchantContact.MerchantId.ShouldBe(TestData.DomainEvents.ContactAddedEvent.MerchantId); merchantContact.Name.ShouldBe(TestData.DomainEvents.ContactAddedEvent.ContactName); @@ -93,9 +93,9 @@ public async Task AddMerchantContact_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, CancellationToken.None); + result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -104,10 +104,10 @@ public async Task AddMerchantDevice_MerchantContractIsAdded() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId); + var merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId, TestContext.Current.CancellationToken); merchantDevice.ShouldNotBeNull(); } @@ -115,9 +115,9 @@ public async Task AddMerchantDevice_MerchantContractIsAdded() public async Task AddMerchantDevice_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, CancellationToken.None); + result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -126,11 +126,11 @@ public async Task AddMerchantOperator_MerchantOperatorIsAdded() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantOperator? merchantOperator = await context.MerchantOperators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorAssignedToMerchantEvent.OperatorId && c.MerchantId == TestData.DomainEvents.OperatorAssignedToMerchantEvent.MerchantId); + MerchantOperator? merchantOperator = await context.MerchantOperators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorAssignedToMerchantEvent.OperatorId && c.MerchantId == TestData.DomainEvents.OperatorAssignedToMerchantEvent.MerchantId, TestContext.Current.CancellationToken); merchantOperator.ShouldNotBeNull(); merchantOperator.Name.ShouldBe(TestData.DomainEvents.OperatorAssignedToMerchantEvent.Name); merchantOperator.MerchantNumber.ShouldBe(TestData.DomainEvents.OperatorAssignedToMerchantEvent.MerchantNumber); @@ -143,9 +143,9 @@ public async Task AddMerchantOperator_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, CancellationToken.None); + result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -154,11 +154,11 @@ public async Task AddMerchantSecurityUser_MerchantSecurityUserIsAdded() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantSecurityUser(TestData.DomainEvents.MerchantSecurityUserAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantSecurityUser(TestData.DomainEvents.MerchantSecurityUserAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantSecurityUser? merchantSecurityUser = await context.MerchantSecurityUsers.SingleOrDefaultAsync(c => c.SecurityUserId == TestData.DomainEvents.MerchantSecurityUserAddedEvent.SecurityUserId); + MerchantSecurityUser? merchantSecurityUser = await context.MerchantSecurityUsers.SingleOrDefaultAsync(c => c.SecurityUserId == TestData.DomainEvents.MerchantSecurityUserAddedEvent.SecurityUserId, TestContext.Current.CancellationToken); merchantSecurityUser.ShouldNotBeNull(); merchantSecurityUser.MerchantId.ShouldBe(TestData.DomainEvents.MerchantSecurityUserAddedEvent.MerchantId); merchantSecurityUser.EmailAddress.ShouldBe(TestData.DomainEvents.MerchantSecurityUserAddedEvent.EmailAddress); @@ -169,9 +169,9 @@ public async Task AddMerchantSecurityUser_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantSecurityUser(TestData.DomainEvents.MerchantSecurityUserAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantSecurityUser(TestData.DomainEvents.MerchantSecurityUserAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddMerchantSecurityUser(TestData.DomainEvents.MerchantSecurityUserAddedEvent, CancellationToken.None); + result = await this.Repository.AddMerchantSecurityUser(TestData.DomainEvents.MerchantSecurityUserAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -180,11 +180,11 @@ public async Task AddMerchantSchedule_MerchantScheduleIsAdded() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantSchedule(TestData.DomainEvents.MerchantScheduleCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantSchedule(TestData.DomainEvents.MerchantScheduleCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantSchedule? merchantSchedule = await context.MerchantSchedules.SingleOrDefaultAsync(c => c.MerchantScheduleId == TestData.DomainEvents.MerchantScheduleCreatedEvent.MerchantScheduleId); + MerchantSchedule? merchantSchedule = await context.MerchantSchedules.SingleOrDefaultAsync(c => c.MerchantScheduleId == TestData.DomainEvents.MerchantScheduleCreatedEvent.MerchantScheduleId, TestContext.Current.CancellationToken); merchantSchedule.ShouldNotBeNull(); merchantSchedule.EstateId.ShouldBe(TestData.DomainEvents.MerchantScheduleCreatedEvent.EstateId); merchantSchedule.MerchantId.ShouldBe(TestData.DomainEvents.MerchantScheduleCreatedEvent.MerchantId); @@ -196,9 +196,9 @@ public async Task AddMerchantSchedule_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantSchedule(TestData.DomainEvents.MerchantScheduleCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantSchedule(TestData.DomainEvents.MerchantScheduleCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddMerchantSchedule(TestData.DomainEvents.MerchantScheduleCreatedEvent, CancellationToken.None); + result = await this.Repository.AddMerchantSchedule(TestData.DomainEvents.MerchantScheduleCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -206,14 +206,14 @@ public async Task AddMerchantSchedule_EventReplayHandled() public async Task RemoveOperatorFromMerchant_MerchantOperatorIsMarkedDeleted() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.RemoveOperatorFromMerchant(TestData.DomainEvents.OperatorRemovedFromMerchantEvent, CancellationToken.None); + result = await this.Repository.RemoveOperatorFromMerchant(TestData.DomainEvents.OperatorRemovedFromMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantOperator? merchantOperator = await context.MerchantOperators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorRemovedFromMerchantEvent.OperatorId && c.MerchantId == TestData.DomainEvents.OperatorRemovedFromMerchantEvent.MerchantId); + MerchantOperator? merchantOperator = await context.MerchantOperators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorRemovedFromMerchantEvent.OperatorId && c.MerchantId == TestData.DomainEvents.OperatorRemovedFromMerchantEvent.MerchantId, TestContext.Current.CancellationToken); merchantOperator.ShouldNotBeNull(); merchantOperator.IsDeleted.ShouldBeTrue(); } @@ -222,12 +222,12 @@ public async Task RemoveOperatorFromMerchant_MerchantOperatorIsMarkedDeleted() public async Task RemoveOperatorFromMerchant_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantOperator(TestData.DomainEvents.OperatorAssignedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.RemoveOperatorFromMerchant(TestData.DomainEvents.OperatorRemovedFromMerchantEvent, CancellationToken.None); + result = await this.Repository.RemoveOperatorFromMerchant(TestData.DomainEvents.OperatorRemovedFromMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.RemoveOperatorFromMerchant(TestData.DomainEvents.OperatorRemovedFromMerchantEvent, CancellationToken.None); + result = await this.Repository.RemoveOperatorFromMerchant(TestData.DomainEvents.OperatorRemovedFromMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -236,17 +236,17 @@ public async Task SwapMerchantDevice_MerchantDeviceIsAdded() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.SwapMerchantDevice(TestData.DomainEvents.DeviceSwappedForMerchantEvent, CancellationToken.None); + result = await this.Repository.SwapMerchantDevice(TestData.DomainEvents.DeviceSwappedForMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId); + var merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId, TestContext.Current.CancellationToken); merchantDevice.ShouldNotBeNull(); merchantDevice.DeviceIdentifier.ShouldBe(TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceIdentifier); merchantDevice.IsEnabled.ShouldBeFalse(); - merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceSwappedForMerchantEvent.DeviceId); + merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceSwappedForMerchantEvent.DeviceId, TestContext.Current.CancellationToken); merchantDevice.ShouldNotBeNull(); merchantDevice.DeviceIdentifier.ShouldBe(TestData.DomainEvents.DeviceSwappedForMerchantEvent.NewDeviceIdentifier); merchantDevice.IsEnabled.ShouldBeTrue(); @@ -257,30 +257,30 @@ public async Task SwapMerchantDevice_EventReplayHandled() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantDevice(TestData.DomainEvents.DeviceAddedToMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.SwapMerchantDevice(TestData.DomainEvents.DeviceSwappedForMerchantEvent, CancellationToken.None); + result = await this.Repository.SwapMerchantDevice(TestData.DomainEvents.DeviceSwappedForMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - var merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId); + var merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId, TestContext.Current.CancellationToken); merchantDevice.ShouldNotBeNull(); merchantDevice.DeviceIdentifier.ShouldBe(TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceIdentifier); merchantDevice.IsEnabled.ShouldBeFalse(); - merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceSwappedForMerchantEvent.DeviceId); + merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceSwappedForMerchantEvent.DeviceId, TestContext.Current.CancellationToken); merchantDevice.ShouldNotBeNull(); merchantDevice.DeviceIdentifier.ShouldBe(TestData.DomainEvents.DeviceSwappedForMerchantEvent.NewDeviceIdentifier); merchantDevice.IsEnabled.ShouldBeTrue(); - result = await this.Repository.SwapMerchantDevice(TestData.DomainEvents.DeviceSwappedForMerchantEvent, CancellationToken.None); + result = await this.Repository.SwapMerchantDevice(TestData.DomainEvents.DeviceSwappedForMerchantEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId); + merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceId, TestContext.Current.CancellationToken); merchantDevice.ShouldNotBeNull(); merchantDevice.DeviceIdentifier.ShouldBe(TestData.DomainEvents.DeviceAddedToMerchantEvent.DeviceIdentifier); merchantDevice.IsEnabled.ShouldBeFalse(); - merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceSwappedForMerchantEvent.DeviceId); + merchantDevice = await context.MerchantDevices.SingleOrDefaultAsync(c => c.DeviceId == TestData.DomainEvents.DeviceSwappedForMerchantEvent.DeviceId, TestContext.Current.CancellationToken); merchantDevice.ShouldNotBeNull(); merchantDevice.DeviceIdentifier.ShouldBe(TestData.DomainEvents.DeviceSwappedForMerchantEvent.NewDeviceIdentifier); merchantDevice.IsEnabled.ShouldBeTrue(); @@ -291,11 +291,11 @@ public async Task UpdateMerchantName_MerchantIsUpdated() { await this.CreateMerchantAsync(); - Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.MerchantNameUpdatedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.MerchantNameUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.MerchantNameUpdatedEvent.MerchantId); + Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.MerchantNameUpdatedEvent.MerchantId, TestContext.Current.CancellationToken); merchant.ShouldNotBeNull(); merchant.Name.ShouldBe(TestData.DomainEvents.MerchantNameUpdatedEvent.MerchantName); } @@ -305,11 +305,11 @@ public async Task UpdateMerchantReference_MerchantIsUpdated() { await this.CreateMerchantAsync(); - Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.MerchantReferenceAllocatedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.MerchantReferenceAllocatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.MerchantReferenceAllocatedEvent.MerchantId); + Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.MerchantReferenceAllocatedEvent.MerchantId, TestContext.Current.CancellationToken); merchant.ShouldNotBeNull(); merchant.Reference.ShouldBe(TestData.DomainEvents.MerchantReferenceAllocatedEvent.MerchantReference); } @@ -319,11 +319,11 @@ public async Task UpdateMerchantSettlementSchedule_MerchantIsUpdated() { await this.CreateMerchantAsync(); - Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.SettlementScheduleChangedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.SettlementScheduleChangedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.SettlementScheduleChangedEvent.MerchantId); + Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(c => c.MerchantId == TestData.DomainEvents.SettlementScheduleChangedEvent.MerchantId, TestContext.Current.CancellationToken); merchant.ShouldNotBeNull(); merchant.SettlementSchedule.ShouldBe(TestData.DomainEvents.SettlementScheduleChangedEvent.SettlementSchedule); } @@ -332,28 +332,28 @@ public async Task UpdateMerchantSettlementSchedule_MerchantIsUpdated() public async Task UpdateMerchantAddress_MerchantAddressIsUpdated() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantAddress(TestData.DomainEvents.AddressAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine1UpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine1UpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine2UpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine2UpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine3UpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine3UpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine4UpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantAddressLine4UpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantCountyUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantCountyUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantRegionUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantRegionUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantTownUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantTownUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantPostalCodeUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantAddress(TestData.DomainEvents.MerchantPostalCodeUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantAddress? merchantAddress = await context.MerchantAddresses.SingleOrDefaultAsync(c => c.AddressId == TestData.DomainEvents.AddressAddedEvent.AddressId); + MerchantAddress? merchantAddress = await context.MerchantAddresses.SingleOrDefaultAsync(c => c.AddressId == TestData.DomainEvents.AddressAddedEvent.AddressId, TestContext.Current.CancellationToken); merchantAddress.ShouldNotBeNull(); merchantAddress.AddressLine1.ShouldBe(TestData.DomainEvents.MerchantAddressLine1UpdatedEvent.AddressLine1); merchantAddress.AddressLine2.ShouldBe(TestData.DomainEvents.MerchantAddressLine2UpdatedEvent.AddressLine2); @@ -369,18 +369,18 @@ public async Task UpdateMerchantAddress_MerchantAddressIsUpdated() public async Task UpdateMerchantContact_MerchantContactIsUpdated() { await this.CreateMerchantAsync(); - Result result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchantContact(TestData.DomainEvents.ContactAddedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantContact(TestData.DomainEvents.MerchantContactNameUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantContact(TestData.DomainEvents.MerchantContactNameUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantContact(TestData.DomainEvents.MerchantContactEmailAddressUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantContact(TestData.DomainEvents.MerchantContactEmailAddressUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantContact(TestData.DomainEvents.MerchantContactPhoneNumberUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateMerchantContact(TestData.DomainEvents.MerchantContactPhoneNumberUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantContact? merchantContact = await context.MerchantContacts.SingleOrDefaultAsync(c => c.ContactId == TestData.DomainEvents.ContactAddedEvent.ContactId); + MerchantContact? merchantContact = await context.MerchantContacts.SingleOrDefaultAsync(c => c.ContactId == TestData.DomainEvents.ContactAddedEvent.ContactId, TestContext.Current.CancellationToken); merchantContact.ShouldNotBeNull(); merchantContact.Name.ShouldBe(TestData.DomainEvents.MerchantContactNameUpdatedEvent.ContactName); merchantContact.EmailAddress.ShouldBe(TestData.DomainEvents.MerchantContactEmailAddressUpdatedEvent.ContactEmailAddress); @@ -392,24 +392,24 @@ public async Task UpdateMerchantOpeningHours_MerchantOpeningHoursIsUpdated() { await this.CreateMerchantAsync(); - Result result = await this.Repository.UpdateMerchantOpeningHours(TestData.DomainEvents.MerchantOpeningHoursUpdatedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateMerchantOpeningHours(TestData.DomainEvents.MerchantOpeningHoursUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Tuesday, "0900", "1800"), CancellationToken.None); + result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Tuesday, "0900", "1800"), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Wednesday, "1000", "1900"), CancellationToken.None); + result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Wednesday, "1000", "1900"), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Thursday, "1100", "2000"), CancellationToken.None); + result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Thursday, "1100", "2000"), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Friday, "1200", "2100"), CancellationToken.None); + result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Friday, "1200", "2100"), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Saturday, "1300", "2200"), CancellationToken.None); + result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Saturday, "1300", "2200"), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Sunday, "1400", "2300"), CancellationToken.None); + result = await this.Repository.UpdateMerchantOpeningHours(CreateMerchantOpeningHoursUpdatedEvent(DayOfWeek.Sunday, "1400", "2300"), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - MerchantOpeningHours? merchantOpeningHours = await context.MerchantOpeningHours.SingleOrDefaultAsync(c => c.MerchantId == TestData.MerchantId); + MerchantOpeningHours? merchantOpeningHours = await context.MerchantOpeningHours.SingleOrDefaultAsync(c => c.MerchantId == TestData.MerchantId, TestContext.Current.CancellationToken); merchantOpeningHours.ShouldNotBeNull(); merchantOpeningHours.MondayOpening.ShouldBe("0800"); merchantOpeningHours.MondayClosing.ShouldBe("1700"); @@ -427,3 +427,5 @@ public async Task UpdateMerchantOpeningHours_MerchantOpeningHoursIsUpdated() merchantOpeningHours.SundayClosing.ShouldBe("2300"); } } + + diff --git a/TransactionProcessor.DatabaseTests/OperatorEventTests.cs b/TransactionProcessor.DatabaseTests/OperatorEventTests.cs index a9a283bd..1c8408c2 100644 --- a/TransactionProcessor.DatabaseTests/OperatorEventTests.cs +++ b/TransactionProcessor.DatabaseTests/OperatorEventTests.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Shouldly; using SimpleResults; using TransactionProcessor.Database.Contexts; @@ -11,10 +11,10 @@ public class OperatorEventTests : BaseTest { [Fact] public async Task AddOperator_OperatorIsAdded() { - Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId); + Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId, TestContext.Current.CancellationToken); @operator.ShouldNotBeNull(); @operator.Name.ShouldBe(TestData.DomainEvents.OperatorCreatedEvent.Name); @operator.RequireCustomMerchantNumber.ShouldBe(TestData.DomainEvents.OperatorCreatedEvent.RequireCustomMerchantNumber); @@ -24,24 +24,24 @@ public async Task AddOperator_OperatorIsAdded() [Fact] public async Task AddOperator_EventReplayHandled() { - Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None); + result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task UpdateOperatorName_OperatorIsUpdated() { - Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateOperator(TestData.DomainEvents.OperatorNameUpdatedEvent, CancellationToken.None); + result = await this.Repository.UpdateOperator(TestData.DomainEvents.OperatorNameUpdatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId); + Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId, TestContext.Current.CancellationToken); @operator.ShouldNotBeNull(); @operator.Name.ShouldBe(TestData.DomainEvents.OperatorNameUpdatedEvent.Name); } @@ -49,14 +49,14 @@ public async Task UpdateOperatorName_OperatorIsUpdated() [Fact] public async Task UpdateOperatorRequireCustomMerchantNumber_OperatorIsUpdated() { - Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateOperator(TestData.DomainEvents.OperatorRequireCustomMerchantNumberChangedEvent, CancellationToken.None); + result = await this.Repository.UpdateOperator(TestData.DomainEvents.OperatorRequireCustomMerchantNumberChangedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId); + Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId, TestContext.Current.CancellationToken); @operator.ShouldNotBeNull(); @operator.RequireCustomMerchantNumber.ShouldBe(TestData.DomainEvents.OperatorRequireCustomMerchantNumberChangedEvent.RequireCustomMerchantNumber); } @@ -64,15 +64,17 @@ public async Task UpdateOperatorRequireCustomMerchantNumber_OperatorIsUpdated() [Fact] public async Task UpdateOperatorRequireCustomTerminalNumber_OperatorIsUpdated() { - Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.UpdateOperator(TestData.DomainEvents.OperatorRequireCustomTerminalNumberChangedEvent, CancellationToken.None); + result = await this.Repository.UpdateOperator(TestData.DomainEvents.OperatorRequireCustomTerminalNumberChangedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId); + Operator? @operator = await context.Operators.SingleOrDefaultAsync(c => c.OperatorId == TestData.DomainEvents.OperatorCreatedEvent.OperatorId, TestContext.Current.CancellationToken); @operator.ShouldNotBeNull(); @operator.RequireCustomTerminalNumber.ShouldBe(TestData.DomainEvents.OperatorRequireCustomTerminalNumberChangedEvent.RequireCustomTerminalNumber); } } + + diff --git a/TransactionProcessor.DatabaseTests/SettlementEventTests.cs b/TransactionProcessor.DatabaseTests/SettlementEventTests.cs index 62bcf264..ea15a9c8 100644 --- a/TransactionProcessor.DatabaseTests/SettlementEventTests.cs +++ b/TransactionProcessor.DatabaseTests/SettlementEventTests.cs @@ -13,35 +13,35 @@ public class SettlementEventTests : BaseTest [Fact] public async Task CreateSettlement_SettlementIsAdded() { - Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, CancellationToken.None); + Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Settlement? settlement = await context.Settlements.SingleOrDefaultAsync(c => c.SettlementId == TestData.DomainEvents.SettlementCreatedForDateEvent.SettlementId); + Settlement? settlement = await context.Settlements.SingleOrDefaultAsync(c => c.SettlementId == TestData.DomainEvents.SettlementCreatedForDateEvent.SettlementId, TestContext.Current.CancellationToken); settlement.ShouldNotBeNull(); } [Fact] public async Task CreateSettlement_EventReplayHandled() { - Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, CancellationToken.None); + Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, CancellationToken.None); + result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task MarkSettlementAsProcessingStarted_SettlementIsUpdated() { - Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, CancellationToken.None); + Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.MarkSettlementAsProcessingStarted(TestData.DomainEvents.SettlementProcessingStartedEvent, CancellationToken.None); + result = await this.Repository.MarkSettlementAsProcessingStarted(TestData.DomainEvents.SettlementProcessingStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Settlement? settlement = await context.Settlements.SingleOrDefaultAsync(c => c.SettlementId == TestData.DomainEvents.SettlementProcessingStartedEvent.SettlementId); + Settlement? settlement = await context.Settlements.SingleOrDefaultAsync(c => c.SettlementId == TestData.DomainEvents.SettlementProcessingStartedEvent.SettlementId, TestContext.Current.CancellationToken); settlement.ShouldNotBeNull(); settlement.ProcessingStarted.ShouldBeTrue(); settlement.ProcessingStartedDateTIme.ShouldBe(TestData.DomainEvents.SettlementProcessingStartedEvent.ProcessingStartedDateTime); @@ -50,14 +50,14 @@ public async Task MarkSettlementAsProcessingStarted_SettlementIsUpdated() [Fact] public async Task MarkSettlementAsCompleted_SettlementIsUpdated() { - Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, CancellationToken.None); + Result result = await this.Repository.CreateSettlement(TestData.DomainEvents.SettlementCreatedForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.MarkSettlementAsCompleted(TestData.DomainEvents.SettlementCompletedEvent, CancellationToken.None); + result = await this.Repository.MarkSettlementAsCompleted(TestData.DomainEvents.SettlementCompletedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Settlement? settlement = await context.Settlements.SingleOrDefaultAsync(c => c.SettlementId == TestData.DomainEvents.SettlementCompletedEvent.SettlementId); + Settlement? settlement = await context.Settlements.SingleOrDefaultAsync(c => c.SettlementId == TestData.DomainEvents.SettlementCompletedEvent.SettlementId, TestContext.Current.CancellationToken); settlement.ShouldNotBeNull(); settlement.IsCompleted.ShouldBeTrue(); } @@ -65,14 +65,15 @@ public async Task MarkSettlementAsCompleted_SettlementIsUpdated() [Fact] public async Task AddPendingMerchantFeeToSettlement_MerchantFeeIsAdded() { - Result result = await this.Repository.AddPendingMerchantFeeToSettlement(TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent, CancellationToken.None); + Result result = await this.Repository.AddPendingMerchantFeeToSettlement(TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); MerchantSettlementFee? merchantSettlementFee = await context.MerchantSettlementFees.SingleOrDefaultAsync(f => f.SettlementId == TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent.SettlementId && f.TransactionId == TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent.TransactionId && - f.ContractProductTransactionFeeId == TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent.FeeId); + f.ContractProductTransactionFeeId == TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent.FeeId, + TestContext.Current.CancellationToken); merchantSettlementFee.ShouldNotBeNull(); merchantSettlementFee.IsSettled.ShouldBeFalse(); @@ -81,24 +82,25 @@ public async Task AddPendingMerchantFeeToSettlement_MerchantFeeIsAdded() [Fact] public async Task AddPendingMerchantFeeToSettlement_EventReplayHandled() { - Result result = await this.Repository.AddPendingMerchantFeeToSettlement(TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent, CancellationToken.None); + Result result = await this.Repository.AddPendingMerchantFeeToSettlement(TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddPendingMerchantFeeToSettlement(TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent, CancellationToken.None); + result = await this.Repository.AddPendingMerchantFeeToSettlement(TestData.DomainEvents.MerchantFeeAddedPendingSettlementEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task AddSettledMerchantFeeToSettlement_MerchantFeeIsAdded() { - Result result = await this.Repository.AddSettledMerchantFeeToSettlement(TestData.SettledMerchantFeeAddedToTransactionEvent(TestData.SettlementDate), CancellationToken.None); + Result result = await this.Repository.AddSettledMerchantFeeToSettlement(TestData.SettledMerchantFeeAddedToTransactionEvent(TestData.SettlementDate), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); MerchantSettlementFee? merchantSettlementFee = await context.MerchantSettlementFees.SingleOrDefaultAsync(f => f.SettlementId == TestData.SettlementAggregateId && f.TransactionId == TestData.SettlementAggregateId && - f.ContractProductTransactionFeeId == TestData.TransactionFeeId); + f.ContractProductTransactionFeeId == TestData.TransactionFeeId, + TestContext.Current.CancellationToken); merchantSettlementFee.ShouldNotBeNull(); merchantSettlementFee.IsSettled.ShouldBeTrue(); @@ -107,10 +109,10 @@ public async Task AddSettledMerchantFeeToSettlement_MerchantFeeIsAdded() [Fact] public async Task AddSettledMerchantFeeToSettlement_EventReplayHandled() { - Result result = await this.Repository.AddSettledMerchantFeeToSettlement(TestData.SettledMerchantFeeAddedToTransactionEvent(TestData.SettlementDate), CancellationToken.None); + Result result = await this.Repository.AddSettledMerchantFeeToSettlement(TestData.SettledMerchantFeeAddedToTransactionEvent(TestData.SettlementDate), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.AddSettledMerchantFeeToSettlement(TestData.SettledMerchantFeeAddedToTransactionEvent(TestData.SettlementDate), CancellationToken.None); + result = await this.Repository.AddSettledMerchantFeeToSettlement(TestData.SettledMerchantFeeAddedToTransactionEvent(TestData.SettlementDate), TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -128,19 +130,21 @@ public async Task MarkMerchantFeeAsSettled_MerchantFeeIsMarkedSettled() TestData.FeeValue, TestData.TransactionFeeCalculateDateTime); - Result result = await this.Repository.AddPendingMerchantFeeToSettlement(pendingEvent, CancellationToken.None); + Result result = await this.Repository.AddPendingMerchantFeeToSettlement(pendingEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.MarkMerchantFeeAsSettled(TestData.DomainEvents.MerchantFeeSettledEvent, CancellationToken.None); + result = await this.Repository.MarkMerchantFeeAsSettled(TestData.DomainEvents.MerchantFeeSettledEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); MerchantSettlementFee? merchantSettlementFee = await context.MerchantSettlementFees.SingleOrDefaultAsync(f => f.SettlementId == TestData.DomainEvents.MerchantFeeSettledEvent.SettlementId && f.TransactionId == TestData.DomainEvents.MerchantFeeSettledEvent.TransactionId && - f.ContractProductTransactionFeeId == TestData.DomainEvents.MerchantFeeSettledEvent.FeeId); + f.ContractProductTransactionFeeId == TestData.DomainEvents.MerchantFeeSettledEvent.FeeId, + TestContext.Current.CancellationToken); merchantSettlementFee.ShouldNotBeNull(); merchantSettlementFee.IsSettled.ShouldBeTrue(); } } + diff --git a/TransactionProcessor.DatabaseTests/StatementEventTests.cs b/TransactionProcessor.DatabaseTests/StatementEventTests.cs index 34a40803..7ecaeb37 100644 --- a/TransactionProcessor.DatabaseTests/StatementEventTests.cs +++ b/TransactionProcessor.DatabaseTests/StatementEventTests.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Shouldly; using SimpleResults; using TransactionProcessor.Database.Contexts; @@ -11,10 +11,10 @@ public class StatementEventTests : BaseTest { [Fact] public async Task CreateStatement_StatementIsAdded() { - Result result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, CancellationToken.None); + Result result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - StatementHeader? statement = await context.StatementHeaders.SingleOrDefaultAsync(c => c.StatementId == TestData.DomainEvents.StatementCreatedEvent.MerchantStatementId); + StatementHeader? statement = await context.StatementHeaders.SingleOrDefaultAsync(c => c.StatementId == TestData.DomainEvents.StatementCreatedEvent.MerchantStatementId, TestContext.Current.CancellationToken); statement.ShouldNotBeNull(); statement.StatementCreatedDate.ShouldBe(TestData.DomainEvents.StatementCreatedEvent.StatementDate.Date); statement.StatementCreatedDateTime.ShouldBe(TestData.DomainEvents.StatementCreatedEvent.StatementDate); @@ -22,24 +22,25 @@ public async Task CreateStatement_StatementIsAdded() [Fact] public async Task CreateStatement_EventReplayHandled() { - Result result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, CancellationToken.None); + Result result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, CancellationToken.None); + result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task MarkStatementAsGenerated_StatementIsUpdated() { - Result result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, CancellationToken.None); + Result result = await this.Repository.CreateStatement(TestData.DomainEvents.StatementCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.MarkStatementAsGenerated(TestData.DomainEvents.StatementGeneratedEvent, CancellationToken.None); + result = await this.Repository.MarkStatementAsGenerated(TestData.DomainEvents.StatementGeneratedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - StatementHeader? statement = await context.StatementHeaders.SingleOrDefaultAsync(c => c.StatementId == TestData.DomainEvents.StatementCreatedEvent.MerchantStatementId); + StatementHeader? statement = await context.StatementHeaders.SingleOrDefaultAsync(c => c.StatementId == TestData.DomainEvents.StatementCreatedEvent.MerchantStatementId, TestContext.Current.CancellationToken); statement.ShouldNotBeNull(); statement.StatementGeneratedDate.ShouldBe(TestData.DomainEvents.StatementGeneratedEvent.DateGenerated); } } + diff --git a/TransactionProcessor.DatabaseTests/TransactionEventTests.cs b/TransactionProcessor.DatabaseTests/TransactionEventTests.cs index aab610eb..73fd3dfd 100644 --- a/TransactionProcessor.DatabaseTests/TransactionEventTests.cs +++ b/TransactionProcessor.DatabaseTests/TransactionEventTests.cs @@ -12,7 +12,7 @@ namespace TransactionProcessor.DatabaseTests; public class TransactionEventTests : BaseTest { private async Task CreateOperatorAsync() { - Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddOperator(TestData.DomainEvents.OperatorCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -20,19 +20,19 @@ private async Task CreateContractAsync() { await this.CreateOperatorAsync(); - Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddContract(TestData.DomainEvents.ContractCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } private async Task CreateMerchantAsync() { - Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, CancellationToken.None); + Result result = await this.Repository.AddMerchant(TestData.DomainEvents.MerchantCreatedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } private async Task CreateTransactionAsync() { - Result result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, CancellationToken.None); + Result result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -41,18 +41,18 @@ private async Task CreateTransactionWithProductDetailsAsync() await this.CreateContractAsync(); await this.CreateTransactionAsync(); - Result result = await this.Repository.AddProductDetailsToTransaction(TestData.DomainEvents.ProductDetailsAddedToTransactionEvent, CancellationToken.None); + Result result = await this.Repository.AddProductDetailsToTransaction(TestData.DomainEvents.ProductDetailsAddedToTransactionEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } [Fact] public async Task StartTransaction_TransactionIsAdded() { - Result result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, CancellationToken.None); + Result result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasStartedEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasStartedEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.MerchantId.ShouldBe(TestData.DomainEvents.TransactionHasStartedEvent.MerchantId); transaction.TransactionDate.ShouldBe(TestData.DomainEvents.TransactionHasStartedEvent.TransactionDateTime.Date); @@ -68,10 +68,10 @@ public async Task StartTransaction_TransactionIsAdded() [Fact] public async Task StartTransaction_EventReplayHandled() { - Result result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, CancellationToken.None); + Result result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); - result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, CancellationToken.None); + result = await this.Repository.StartTransaction(TestData.DomainEvents.TransactionHasStartedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); } @@ -80,11 +80,11 @@ public async Task CompleteTransaction_TransactionIsCompleted() { await this.CreateTransactionAsync(); - Result result = await this.Repository.CompleteTransaction(TestData.DomainEvents.TransactionHasBeenCompletedEvent, CancellationToken.None); + Result result = await this.Repository.CompleteTransaction(TestData.DomainEvents.TransactionHasBeenCompletedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasBeenCompletedEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasBeenCompletedEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.IsCompleted.ShouldBeTrue(); } @@ -92,11 +92,11 @@ public async Task CompleteTransaction_TransactionIsCompleted() [Fact] public async Task RecordTransactionAdditionalRequestData_RequestDataIsStored() { - Result result = await this.Repository.RecordTransactionAdditionalRequestData(TestData.DomainEvents.AdditionalRequestDataRecordedEvent, CancellationToken.None); + Result result = await this.Repository.RecordTransactionAdditionalRequestData(TestData.DomainEvents.AdditionalRequestDataRecordedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - TransactionAdditionalRequestData? requestData = await context.TransactionsAdditionalRequestData.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.AdditionalRequestDataRecordedEvent.TransactionId); + TransactionAdditionalRequestData? requestData = await context.TransactionsAdditionalRequestData.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.AdditionalRequestDataRecordedEvent.TransactionId, TestContext.Current.CancellationToken); requestData.ShouldNotBeNull(); requestData.Amount.ShouldBe("123.45"); requestData.CustomerAccountNumber.ShouldBe("12345678"); @@ -105,11 +105,11 @@ public async Task RecordTransactionAdditionalRequestData_RequestDataIsStored() [Fact] public async Task RecordTransactionAdditionalResponseData_ResponseDataIsStored() { - Result result = await this.Repository.RecordTransactionAdditionalResponseData(TestData.DomainEvents.AdditionalResponseDataRecordedEvent, CancellationToken.None); + Result result = await this.Repository.RecordTransactionAdditionalResponseData(TestData.DomainEvents.AdditionalResponseDataRecordedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - TransactionAdditionalResponseData? responseData = await context.TransactionsAdditionalResponseData.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.AdditionalResponseDataRecordedEvent.TransactionId); + TransactionAdditionalResponseData? responseData = await context.TransactionsAdditionalResponseData.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.AdditionalResponseDataRecordedEvent.TransactionId, TestContext.Current.CancellationToken); responseData.ShouldNotBeNull(); responseData.TransactionId.ShouldBe(TestData.DomainEvents.AdditionalResponseDataRecordedEvent.TransactionId); responseData.TransactionReportingId.ShouldBe(0); @@ -120,11 +120,11 @@ public async Task SetTransactionAmount_TransactionAmountIsUpdated() { await this.CreateTransactionAsync(); - Result result = await this.Repository.SetTransactionAmount(TestData.DomainEvents.AdditionalRequestDataRecordedEvent, CancellationToken.None); + Result result = await this.Repository.SetTransactionAmount(TestData.DomainEvents.AdditionalRequestDataRecordedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasStartedEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasStartedEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.TransactionAmount.ShouldBe(123.45m); } @@ -135,11 +135,11 @@ public async Task AddProductDetailsToTransaction_TransactionIsUpdated() await this.CreateContractAsync(); await this.CreateTransactionAsync(); - Result result = await this.Repository.AddProductDetailsToTransaction(TestData.DomainEvents.ProductDetailsAddedToTransactionEvent, CancellationToken.None); + Result result = await this.Repository.AddProductDetailsToTransaction(TestData.DomainEvents.ProductDetailsAddedToTransactionEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.ProductDetailsAddedToTransactionEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.ProductDetailsAddedToTransactionEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.ContractId.ShouldBe(TestData.DomainEvents.ProductDetailsAddedToTransactionEvent.ContractId); transaction.ContractProductId.ShouldBe(TestData.DomainEvents.ProductDetailsAddedToTransactionEvent.ProductId); @@ -151,11 +151,11 @@ public async Task AddSourceDetailsToTransaction_TransactionSourceIsUpdated() { await this.CreateTransactionAsync(); - Result result = await this.Repository.AddSourceDetailsToTransaction(TestData.DomainEvents.TransactionSourceAddedToTransactionEvent, CancellationToken.None); + Result result = await this.Repository.AddSourceDetailsToTransaction(TestData.DomainEvents.TransactionSourceAddedToTransactionEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionSourceAddedToTransactionEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionSourceAddedToTransactionEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.TransactionSource.ShouldBe(TestData.DomainEvents.TransactionSourceAddedToTransactionEvent.TransactionSource); } @@ -165,11 +165,11 @@ public async Task UpdateTransactionAuthorisation_LocallyAuthorisedTransactionIsU { await this.CreateTransactionAsync(); - Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionHasBeenLocallyAuthorisedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionHasBeenLocallyAuthorisedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasBeenLocallyAuthorisedEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasBeenLocallyAuthorisedEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.IsAuthorised.ShouldBeTrue(); transaction.AuthorisationCode.ShouldBe(TestData.AuthorisationCode); @@ -182,11 +182,11 @@ public async Task UpdateTransactionAuthorisation_LocallyDeclinedTransactionIsUpd { await this.CreateTransactionAsync(); - Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionHasBeenLocallyDeclinedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionHasBeenLocallyDeclinedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasBeenLocallyDeclinedEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionHasBeenLocallyDeclinedEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.IsAuthorised.ShouldBeFalse(); transaction.ResponseCode.ShouldBe(TestData.DeclinedResponseCode.ToCodeString()); @@ -198,11 +198,11 @@ public async Task UpdateTransactionAuthorisation_OperatorAuthorisedTransactionIs { await this.CreateTransactionAsync(); - Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionAuthorisedByOperatorEvent, CancellationToken.None); + Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionAuthorisedByOperatorEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionAuthorisedByOperatorEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionAuthorisedByOperatorEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.IsAuthorised.ShouldBeTrue(); transaction.AuthorisationCode.ShouldBe(TestData.OperatorAuthorisationCode); @@ -215,11 +215,11 @@ public async Task UpdateTransactionAuthorisation_OperatorDeclinedTransactionIsUp { await this.CreateTransactionAsync(); - Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionDeclinedByOperatorEvent, CancellationToken.None); + Result result = await this.Repository.UpdateTransactionAuthorisation(TestData.DomainEvents.TransactionDeclinedByOperatorEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionDeclinedByOperatorEvent.TransactionId); + Transaction? transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionDeclinedByOperatorEvent.TransactionId, TestContext.Current.CancellationToken); transaction.ShouldNotBeNull(); transaction.IsAuthorised.ShouldBeFalse(); transaction.ResponseCode.ShouldBe(TestData.DeclinedResponseCode.ToCodeString()); @@ -229,11 +229,11 @@ public async Task UpdateTransactionAuthorisation_OperatorDeclinedTransactionIsUp [Fact] public async Task RecordTransactionTimings_TimingsAreStored() { - Result result = await this.Repository.RecordTransactionTimings(TestData.DomainEvents.TransactionTimingsAddedToTransactionEvent, CancellationToken.None); + Result result = await this.Repository.RecordTransactionTimings(TestData.DomainEvents.TransactionTimingsAddedToTransactionEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - TransactionTimings? timings = await context.TransactionTimings.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionTimingsAddedToTransactionEvent.TransactionId); + TransactionTimings? timings = await context.TransactionTimings.SingleOrDefaultAsync(t => t.TransactionId == TestData.DomainEvents.TransactionTimingsAddedToTransactionEvent.TransactionId, TestContext.Current.CancellationToken); timings.ShouldNotBeNull(); timings.TransactionStartedDateTime.ShouldBe(TestData.DomainEvents.TransactionTimingsAddedToTransactionEvent.TransactionStartedDateTime); timings.OperatorCommunicationsStartedDateTime.ShouldBe(TestData.DomainEvents.TransactionTimingsAddedToTransactionEvent.OperatorCommunicationsStartedEvent); @@ -249,11 +249,11 @@ public async Task AddTransactionToStatement_StatementLineIsAdded() { await this.CreateTransactionWithProductDetailsAsync(); - Result result = await this.Repository.AddTransactionToStatement(TestData.DomainEvents.TransactionAddedToStatementForDateEvent, CancellationToken.None); + Result result = await this.Repository.AddTransactionToStatement(TestData.DomainEvents.TransactionAddedToStatementForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - StatementLine? statementLine = await context.StatementLines.SingleOrDefaultAsync(s => s.StatementId == TestData.DomainEvents.TransactionAddedToStatementForDateEvent.MerchantStatementId && s.TransactionId == TestData.DomainEvents.TransactionAddedToStatementForDateEvent.TransactionId); + StatementLine? statementLine = await context.StatementLines.SingleOrDefaultAsync(s => s.StatementId == TestData.DomainEvents.TransactionAddedToStatementForDateEvent.MerchantStatementId && s.TransactionId == TestData.DomainEvents.TransactionAddedToStatementForDateEvent.TransactionId, TestContext.Current.CancellationToken); statementLine.ShouldNotBeNull(); statementLine.ActivityDate.ShouldBe(TestData.DomainEvents.TransactionAddedToStatementForDateEvent.TransactionDateTime.Date); statementLine.ActivityDateTime.ShouldBe(TestData.DomainEvents.TransactionAddedToStatementForDateEvent.TransactionDateTime); @@ -268,11 +268,11 @@ public async Task AddSettledFeeToStatement_StatementLineIsAdded() { await this.CreateTransactionWithProductDetailsAsync(); - Result result = await this.Repository.AddSettledFeeToStatement(TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent, CancellationToken.None); + Result result = await this.Repository.AddSettledFeeToStatement(TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - StatementLine? statementLine = await context.StatementLines.SingleOrDefaultAsync(s => s.StatementId == TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent.MerchantStatementId && s.TransactionId == TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent.TransactionId); + StatementLine? statementLine = await context.StatementLines.SingleOrDefaultAsync(s => s.StatementId == TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent.MerchantStatementId && s.TransactionId == TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent.TransactionId, TestContext.Current.CancellationToken); statementLine.ShouldNotBeNull(); statementLine.ActivityDate.ShouldBe(TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent.SettledDateTime.Date); statementLine.ActivityDateTime.ShouldBe(TestData.DomainEvents.SettledFeeAddedToStatementForDateEvent.SettledDateTime); @@ -287,13 +287,15 @@ public async Task UpdateMerchant_TransactionCompletionUpdatesMerchantLastSale() { await this.CreateMerchantAsync(); - Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.TransactionHasBeenCompletedEvent, CancellationToken.None); + Result result = await this.Repository.UpdateMerchant(TestData.DomainEvents.TransactionHasBeenCompletedEvent, TestContext.Current.CancellationToken); result.IsSuccess.ShouldBeTrue(); EstateManagementContext context = this.GetContext(); - Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(m => m.MerchantId == TestData.DomainEvents.TransactionHasBeenCompletedEvent.MerchantId); + Merchant? merchant = await context.Merchants.SingleOrDefaultAsync(m => m.MerchantId == TestData.DomainEvents.TransactionHasBeenCompletedEvent.MerchantId, TestContext.Current.CancellationToken); merchant.ShouldNotBeNull(); merchant.LastSaleDate.ShouldBe(TestData.DomainEvents.TransactionHasBeenCompletedEvent.CompletedDateTime.Date); merchant.LastSaleDateTime.ShouldBe(TestData.DomainEvents.TransactionHasBeenCompletedEvent.CompletedDateTime); } } + + diff --git a/TransactionProcessor.DomainEvents/FloatDomainEvents.cs b/TransactionProcessor.DomainEvents/FloatDomainEvents.cs index 617214c4..6772bb09 100644 --- a/TransactionProcessor.DomainEvents/FloatDomainEvents.cs +++ b/TransactionProcessor.DomainEvents/FloatDomainEvents.cs @@ -5,7 +5,8 @@ namespace TransactionProcessor.DomainEvents; [ExcludeFromCodeCoverage] public class FloatDomainEvents { + public record FloatCreatedEvent(Guid FloatId, Guid EstateId, DateTime CreatedDateTime) : DomainEvent(FloatId, Guid.NewGuid()); public record FloatCreatedForContractProductEvent(Guid FloatId, Guid EstateId, Guid ContractId, Guid ProductId, DateTime CreatedDateTime) : DomainEvent(FloatId, Guid.NewGuid()); public record FloatCreditPurchasedEvent(Guid FloatId, Guid EstateId, DateTime CreditPurchasedDateTime, Decimal Amount, Decimal CostPrice) : DomainEvent(FloatId, Guid.NewGuid()); public record FloatDecreasedByTransactionEvent(Guid FloatId, Guid EstateId, Guid TransactionId, Decimal Amount) : DomainEvent(FloatId, Guid.NewGuid()); -} \ No newline at end of file +} diff --git a/TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs b/TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs index 5b9f63aa..9b2cc043 100644 --- a/TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs +++ b/TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs @@ -122,6 +122,9 @@ Task CompleteReconciliation(ReconciliationDomainEvents.ReconciliationHas Task CompleteTransaction(TransactionDomainEvents.TransactionHasBeenCompletedEvent domainEvent, CancellationToken cancellationToken); + Task CreateFloat(FloatDomainEvents.FloatCreatedEvent domainEvent, + CancellationToken cancellationToken); + Task CreateFloat(FloatDomainEvents.FloatCreatedForContractProductEvent domainEvent, CancellationToken cancellationToken); @@ -1274,7 +1277,7 @@ public async Task CompleteTransaction(TransactionDomainEvents.Transactio return await context.SaveChangesAsync(cancellationToken); } - public async Task CreateFloat(FloatDomainEvents.FloatCreatedForContractProductEvent domainEvent, + public async Task CreateFloat(FloatDomainEvents.FloatCreatedEvent domainEvent, CancellationToken cancellationToken) { using ResolvedDbContext? resolvedContext = this.Resolver.Resolve(EstateManagementDatabaseName, domainEvent.EstateId.ToString()); await using EstateManagementContext context = resolvedContext.Context; @@ -1283,15 +1286,19 @@ public async Task CreateFloat(FloatDomainEvents.FloatCreatedForContractP { CreatedDate = domainEvent.CreatedDateTime.Date, CreatedDateTime = domainEvent.CreatedDateTime, - ContractId = domainEvent.ContractId, EstateId = domainEvent.EstateId, FloatId = domainEvent.FloatId, - ProductId = domainEvent.ProductId }; await context.Floats.AddAsync(floatRecord, cancellationToken); return await context.SaveChangesWithDuplicateHandling(cancellationToken); } + public async Task CreateFloat(FloatDomainEvents.FloatCreatedForContractProductEvent domainEvent, + CancellationToken cancellationToken) + { + return await this.CreateFloat(new FloatDomainEvents.FloatCreatedEvent(domainEvent.FloatId, domainEvent.EstateId, domainEvent.CreatedDateTime), cancellationToken); + } + public async Task CreateFloatActivity(FloatDomainEvents.FloatCreditPurchasedEvent domainEvent, CancellationToken cancellationToken) { using ResolvedDbContext? resolvedContext = this.Resolver.Resolve(EstateManagementDatabaseName, domainEvent.EstateId.ToString()); diff --git a/TransactionProcessor.Testing/TestData.cs b/TransactionProcessor.Testing/TestData.cs index 3a624225..7c43a643 100644 --- a/TransactionProcessor.Testing/TestData.cs +++ b/TransactionProcessor.Testing/TestData.cs @@ -1276,7 +1276,7 @@ public static FloatActivityAggregate GetEmptyFloatActivityAggregate() public static FloatAggregate GetFloatAggregateWithCostValues(){ FloatAggregate floatAggregate = FloatAggregate.Create(TestData.FloatAggregateId); - floatAggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + floatAggregate.CreateFloat(TestData.EstateId, TestData.FloatCreatedDateTime); floatAggregate.RecordCreditPurchase(DateTime.Now, TestData.FloatCreditAmount, TestData.FloatCreditCostPrice); return floatAggregate; } @@ -1739,7 +1739,7 @@ public static SettlementAggregate GetSettlementAggregateWithNotAllFeesSettled(In public static FloatCommands.RecordCreditPurchaseForFloatCommand RecordCreditPurchaseForFloatCommand => new(TestData.EstateId, TestData.FloatAggregateId, TestData.FloatCreditAmount, TestData.FloatCreditCostPrice, TestData.CreditPurchasedDateTime); - public static FloatCommands.CreateFloatForContractProductCommand CreateFloatForContractProductCommand => new(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + public static FloatCommands.CreateFloatCommand CreateFloatCommand => new(TestData.EstateId, TestData.FloatAggregateId, TestData.FloatCreatedDateTime); public static RedeemVoucherResponse RedeemVoucherResponse => new RedeemVoucherResponse @@ -2622,7 +2622,8 @@ public static class DomainEvents { public static ReconciliationDomainEvents.ReconciliationHasStartedEvent ReconciliationHasStartedEvent => new ReconciliationDomainEvents.ReconciliationHasStartedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, TestData.TransactionDateTime); - public static FloatDomainEvents.FloatCreatedForContractProductEvent FloatCreatedForContractProductEvent => new FloatDomainEvents.FloatCreatedForContractProductEvent(FloatAggregateId, EstateId, ContractId, VariableContractProductId, FloatCreatedDateTime); + public static FloatDomainEvents.FloatCreatedForContractProductEvent FloatCreatedForContractProductEvent => new FloatDomainEvents.FloatCreatedForContractProductEvent(FloatAggregateId, EstateId, ContractId, ProductId, FloatCreatedDateTime); + public static FloatDomainEvents.FloatCreatedEvent FloatCreatedEvent => new FloatDomainEvents.FloatCreatedEvent(FloatAggregateId, EstateId, FloatCreatedDateTime); public static TransactionDomainEvents.TransactionHasStartedEvent TransactionHasStartedEvent => new TransactionDomainEvents.TransactionHasStartedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, TestData.TransactionDateTime1, TestData.TransactionNumber, TestData.TransactionTypeSale.ToString(), TestData.TransactionReference, TestData.DeviceIdentifier, TestData.TransactionAmount); public static TransactionDomainEvents.AdditionalRequestDataRecordedEvent AdditionalRequestDataRecordedEvent => new TransactionDomainEvents.AdditionalRequestDataRecordedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, TestData.OperatorId, new Dictionary { diff --git a/TransactionProcessor.Tests/HandlerTests/WebHandlersTests.cs b/TransactionProcessor.Tests/HandlerTests/WebHandlersTests.cs index 33dd6c8e..dd701465 100644 --- a/TransactionProcessor.Tests/HandlerTests/WebHandlersTests.cs +++ b/TransactionProcessor.Tests/HandlerTests/WebHandlersTests.cs @@ -363,19 +363,16 @@ public static IEnumerable FloatCases() { yield return Case( "CreateFloatForContractProduct", - SetupSuccess(command => + SetupSuccess(command => { command.EstateId.ShouldBe(EstateId); - command.ContractId.ShouldBe(ContractId); - command.ProductId.ShouldBe(ProductId); }), - mediator => FloatHandlers.CreateFloatForContractProduct(mediator, + mediator => FloatHandlers.CreateFloat(mediator, new DefaultHttpContext(), EstateId, - new CreateFloatForContractProductRequest + new CreateFloatRequest { - ContractId = ContractId, - ProductId = ProductId, + FloatId = FloatId, CreateDateTime = Instant }, CancellationToken.None)); diff --git a/TransactionProcessor/Endpoints/FloatEndpoints.cs b/TransactionProcessor/Endpoints/FloatEndpoints.cs index a1b862ed..4be0fe51 100644 --- a/TransactionProcessor/Endpoints/FloatEndpoints.cs +++ b/TransactionProcessor/Endpoints/FloatEndpoints.cs @@ -19,8 +19,8 @@ public static IEndpointRouteBuilder MapFloatEndpoints(this IEndpointRouteBuilder .RequireAuthorization() .RequireAuthorization(AuthorizationExtensions.PolicyNames.ClientCredentialsOnlyPolicy); - group.MapPost("/", FloatHandlers.CreateFloatForContractProduct) - .WithName("CreateFloatForContractProduct"); + group.MapPost("/", FloatHandlers.CreateFloat) + .WithName("CreateFloat"); group.MapPut("/", FloatHandlers.RecordFloatCreditPurchase) .WithName("RecordFloatCreditPurchase"); diff --git a/TransactionProcessor/Handlers/FloatHandlers.cs b/TransactionProcessor/Handlers/FloatHandlers.cs index 948ef257..c4b9961b 100644 --- a/TransactionProcessor/Handlers/FloatHandlers.cs +++ b/TransactionProcessor/Handlers/FloatHandlers.cs @@ -13,9 +13,9 @@ namespace TransactionProcessor.Handlers { public static class FloatHandlers { - public static async Task CreateFloatForContractProduct(IMediator mediator, HttpContext ctx, Guid estateId, CreateFloatForContractProductRequest createFloatRequest, CancellationToken cancellationToken) + public static async Task CreateFloat(IMediator mediator, HttpContext ctx, Guid estateId, CreateFloatRequest createFloatRequest, CancellationToken cancellationToken) { - FloatCommands.CreateFloatForContractProductCommand command = new(estateId, createFloatRequest.ContractId, createFloatRequest.ProductId, createFloatRequest.CreateDateTime); + FloatCommands.CreateFloatCommand command = new(estateId, createFloatRequest.FloatId, createFloatRequest.CreateDateTime); Result result = await mediator.Send(command, cancellationToken); return ResponseFactory.FromResult(result);