diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index 3df1ebc7..8bee448d 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -5,29 +5,7 @@ on: - cron: "10 23 * * *" repository_dispatch: -jobs: - check: - runs-on: ubuntu-latest - name: Check latest commit - outputs: - commitcount: ${{ steps.commitswithintime.outputs.number-of-commits-within-time }} - steps: - - uses: actions/checkout@v2 - #with: - #fetch-depth: 0 - - - name: Check for commits within time - uses: TransactionProcessing/CommitsWithinTime@1.0.0 - id: commitswithintime - with: - hours: 24 - - - name: Get the output from CommitsWithinTime - run: | - echo "The 'has-new-commits-within-time' value is ${{ steps.commitswithintime.outputs.has-new-commits-within-time }}" - echo "The 'number-of-commits-within-time' value is ${{ steps.commitswithintime.outputs.number-of-commits-within-time }}" - echo "The 'total-commits' value is ${{ steps.commitswithintime.outputs.total-commits }}" - +jobs: build: name: "Nightly Build" env: @@ -35,9 +13,6 @@ jobs: runs-on: ubuntu-latest - needs: check - if: ${{ needs.check.outputs.commitcount > 0 }} - steps: - uses: actions/checkout@v2.3.4 diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs index 74c9faa6..79c4621d 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs @@ -12,6 +12,7 @@ using EstateManagement.DataTransferObjects; using EstateManagement.DataTransferObjects.Responses; using EventHandling; + using FloatAggregate; using MessagingService.Client; using MessagingService.DataTransferObjects; using Microsoft.Extensions.Configuration; @@ -45,12 +46,15 @@ public class TransactionDomainEventHandlerTests private Mock MessagingServiceClient; + private Mock> FloatAggregateRepository; + private TransactionDomainEventHandler TransactionDomainEventHandler; public TransactionDomainEventHandlerTests() { this.SettlementAggregateRepository = new Mock>(); this.TransactionAggregateRepository = new Mock>(); + this.FloatAggregateRepository = new Mock>(); this.FeeCalculationManager = new Mock(); this.EstateClient = new Mock(); this.SecurityServiceClient = new Mock(); @@ -62,12 +66,13 @@ public TransactionDomainEventHandlerTests() Logger.Initialise(NullLogger.Instance); this.TransactionDomainEventHandler = new TransactionDomainEventHandler(this.TransactionAggregateRepository.Object, - this.FeeCalculationManager.Object, - this.EstateClient.Object, - this.SecurityServiceClient.Object, - this.TransactionReceiptBuilder.Object, - this.MessagingServiceClient.Object, - this.SettlementAggregateRepository.Object); + this.FeeCalculationManager.Object, + this.EstateClient.Object, + this.SecurityServiceClient.Object, + this.TransactionReceiptBuilder.Object, + this.MessagingServiceClient.Object, + this.SettlementAggregateRepository.Object, + this.FloatAggregateRepository.Object); } [Theory] @@ -76,6 +81,8 @@ public TransactionDomainEventHandlerTests() [InlineData(SettlementSchedule.Monthly)] public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_SuccessfulSale_EventIsHandled(SettlementSchedule settlementSchedule) { + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + TransactionAggregate transactionAggregate = TestData.GetCompletedAuthorisedSaleTransactionAggregate(); this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) .ReturnsAsync(transactionAggregate); @@ -125,6 +132,8 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet [Fact] public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_SuccessfulSale_MerchantWithNotSetSettlementSchedule_ErrorThrown() { + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + TransactionAggregate transactionAggregate = TestData.GetCompletedAuthorisedSaleTransactionAggregate(); this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) .ReturnsAsync(transactionAggregate); @@ -158,6 +167,8 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet [Fact] public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_UnsuccessfulSale_EventIsHandled() { + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetCompletedDeclinedSaleTransactionAggregate); @@ -167,6 +178,8 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet [Fact] public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_IncompleteSale_EventIsHandled() { + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetIncompleteAuthorisedSaleTransactionAggregate); await this.TransactionDomainEventHandler.Handle(TestData.TransactionHasBeenCompletedEvent, CancellationToken.None); @@ -175,6 +188,8 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet [Fact] public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_SaleWithNoProductDetails_EventIsHandled() { + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetCompletedAuthorisedSaleWithNoProductDetailsTransactionAggregate); @@ -182,8 +197,9 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet } [Fact] - public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_AuthorisedLogon_EventIsHandled() - { + public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_AuthorisedLogon_EventIsHandled(){ + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetCompletedAuthorisedLogonTransactionAggregate); @@ -213,6 +229,43 @@ public async Task TransactionDomainEventHandler_Handle_CustomerEmailReceiptResen It.IsAny()), Times.Once); } + [Fact] + public async Task TransactionDomainEventHandler_Handle_TransactionCostInformationRecordedEvent_EventIsHandled(){ + this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(TestData.GetCompletedAuthorisedSaleTransactionAggregate); + + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + + await this.TransactionDomainEventHandler.Handle(TestData.TransactionCostInformationRecordedEvent, CancellationToken.None); + + this.FloatAggregateRepository.Verify(f => f.SaveChanges(It.IsAny(), It.IsAny()), Times.Once); + } + + [Fact] + public async Task TransactionDomainEventHandler_Handle_TransactionCostInformationRecordedEvent_TransactionNotAuthorised_EventIsHandled() + { + this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(TestData.GetCompletedDeclinedSaleTransactionAggregate); + + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + + await this.TransactionDomainEventHandler.Handle(TestData.TransactionCostInformationRecordedEvent, CancellationToken.None); + + this.FloatAggregateRepository.Verify(f => f.SaveChanges(It.IsAny(), It.IsAny()), Times.Never); + } + + [Fact] + public async Task TransactionDomainEventHandler_Handle_TransactionCostInformationRecordedEvent_TransactionNotCompleted_EventIsHandled() + { + this.TransactionAggregateRepository.Setup(t => t.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(TestData.GetIncompleteAuthorisedSaleTransactionAggregate); + + this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues); + + await this.TransactionDomainEventHandler.Handle(TestData.TransactionCostInformationRecordedEvent, CancellationToken.None); + + this.FloatAggregateRepository.Verify(f => f.SaveChanges(It.IsAny(), It.IsAny()), Times.Never); + } //[Fact] //public async Task TransactionDomainEventHandler_Handle_MerchantFeeAddedToTransactionEvent_EventIsHandled() diff --git a/TransactionProcessor.BusinessLogic/Common/Extensions.cs b/TransactionProcessor.BusinessLogic/Common/Extensions.cs index f1f21f22..b0ad214a 100644 --- a/TransactionProcessor.BusinessLogic/Common/Extensions.cs +++ b/TransactionProcessor.BusinessLogic/Common/Extensions.cs @@ -8,6 +8,7 @@ namespace TransactionProcessor.BusinessLogic.Common { using Google.Protobuf.WellKnownTypes; using System.Diagnostics.CodeAnalysis; + using Shared.General; using Type = System.Type; public static class Helpers @@ -20,97 +21,7 @@ public static Guid CalculateSettlementAggregateId(DateTime settlementDate, return aggregateId; } } - - public static class GuidCalculator - { - #region Methods - - /// - /// Combines the specified GUIDs into a new GUID. - /// - /// The first unique identifier. - /// The second unique identifier. - /// The offset. - /// Guid. - public static Guid Combine(Guid firstGuid, - Guid secondGuid, - Byte offset) - { - Byte[] firstAsBytes = firstGuid.ToByteArray(); - Byte[] secondAsBytes = secondGuid.ToByteArray(); - - Byte[] newBytes = new Byte[16]; - - for (Int32 i = 0; i < 16; i++) - { - // Add and truncate any overflow - newBytes[i] = (Byte)(firstAsBytes[i] + secondAsBytes[i] + offset); - } - - return new Guid(newBytes); - } - - /// - /// Combines the specified GUIDs into a new GUID. - /// - /// The first unique identifier. - /// The second unique identifier. - /// Guid. - public static Guid Combine(Guid firstGuid, - Guid secondGuid) - { - return GuidCalculator.Combine(firstGuid, - secondGuid, - 0); - } - - /// - /// Combines the specified first unique identifier. - /// - /// The first unique identifier. - /// The second unique identifier. - /// The third unique identifier. - /// The offset. - /// Guid. - public static Guid Combine(Guid firstGuid, - Guid secondGuid, - Guid thirdGuid, - Byte offset) - { - Byte[] firstAsBytes = firstGuid.ToByteArray(); - Byte[] secondAsBytes = secondGuid.ToByteArray(); - Byte[] thirdAsBytes = thirdGuid.ToByteArray(); - - Byte[] newBytes = new Byte[16]; - - for (Int32 i = 0; i < 16; i++) - { - // Add and truncate any overflow - newBytes[i] = (Byte)(firstAsBytes[i] + secondAsBytes[i] + thirdAsBytes[i] + offset); - } - - return new Guid(newBytes); - } - - /// - /// Combines the specified first unique identifier. - /// - /// The first unique identifier. - /// The second unique identifier. - /// The third unique identifier. - /// Guid. - public static Guid Combine(Guid firstGuid, - Guid secondGuid, - Guid thirdGuid) - { - return GuidCalculator.Combine(firstGuid, - secondGuid, - thirdGuid, - 0); - } - - #endregion - } + public static class Extensions { /// diff --git a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs index 77446884..91bc0280 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs @@ -8,8 +8,10 @@ using System.Threading.Tasks; using Common; using EstateManagement.Client; + using EstateManagement.Database.Entities; using EstateManagement.DataTransferObjects; using EstateManagement.DataTransferObjects.Responses; + using FloatAggregate; using Manager; using MessagingService.Client; using MessagingService.DataTransferObjects; @@ -27,6 +29,7 @@ using Transaction.DomainEvents; using TransactionAggregate; using CalculationType = Models.CalculationType; + using ContractProductTransactionFee = EstateManagement.DataTransferObjects.Responses.ContractProductTransactionFee; using FeeType = Models.FeeType; /// @@ -60,6 +63,8 @@ public class TransactionDomainEventHandler : IDomainEventHandler private readonly IAggregateRepository SettlementAggregateRepository; + private readonly IAggregateRepository FloatAggregateRepository; + private readonly IAggregateRepository TransactionAggregateRepository; /// @@ -82,7 +87,8 @@ public TransactionDomainEventHandler(IAggregateRepository settlementAggregateRepository) { + IAggregateRepository settlementAggregateRepository, + IAggregateRepository floatAggregateRepository) { this.TransactionAggregateRepository = transactionAggregateRepository; this.FeeCalculationManager = feeCalculationManager; this.EstateClient = estateClient; @@ -90,6 +96,7 @@ public TransactionDomainEventHandler(IAggregateRepository(() => { + aggregate.RecordTransactionAgainstFloat(TestData.TransactionId, 100); + }); + } + + [Fact] + public void FloatAggregate_RecordTransactionAgainstFloat_DuplicateTransaction_ErrorThrown() + { + FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); + DateTime purchaseDateTime = DateTime.Now; + aggregate.RecordCreditPurchase(purchaseDateTime, 1000, 900); + aggregate.RecordTransactionAgainstFloat(TestData.TransactionId, 100); + Should.Throw(() => { + aggregate.RecordTransactionAgainstFloat(TestData.TransactionId, 100); + }); + } } } \ No newline at end of file diff --git a/TransactionProcessor.FloatAggregate/FloatAggregate.cs b/TransactionProcessor.FloatAggregate/FloatAggregate.cs index 2a0d18bc..77457ead 100644 --- a/TransactionProcessor.FloatAggregate/FloatAggregate.cs +++ b/TransactionProcessor.FloatAggregate/FloatAggregate.cs @@ -27,6 +27,13 @@ public static void PlayEvent(this FloatAggregate aggregate, FloatCreditPurchased aggregate.Credits.Add((domainEvent.CreditPurchasedDateTime, domainEvent.Amount,domainEvent.CostPrice)); } + public static void PlayEvent(this FloatAggregate aggregate, FloatDecreasedByTransactionEvent domainEvent){ + aggregate.Balance -= domainEvent.Amount; + aggregate.NumberOfTransactions++; + aggregate.TotalTransactions += domainEvent.Amount; + aggregate.Transactions.Add((domainEvent.TransactionId, domainEvent.Amount)); + } + public static void CreateFloat(this FloatAggregate aggregate, Guid estateId, Guid contractId, @@ -53,6 +60,15 @@ public static void RecordCreditPurchase(this FloatAggregate aggregate, DateTime aggregate.ApplyAndAppend(floatCreditPurchasedEvent); } + public static void RecordTransactionAgainstFloat(this FloatAggregate aggregate, Guid transactionId, Decimal transactionAmount){ + aggregate.ValidateFloatIsAlreadyCreated(); + aggregate.ValidateTransactionIsNotADuplicate(transactionId); + + FloatDecreasedByTransactionEvent floatDecreasedByTransactionEvent = new FloatDecreasedByTransactionEvent(aggregate.AggregateId, aggregate.EstateId, transactionId, transactionAmount); + + aggregate.ApplyAndAppend(floatDecreasedByTransactionEvent); + } + public static Decimal GetUnitCostPrice(this FloatAggregate aggregate) { return Math.Round(aggregate.UnitCostPrice, 4); @@ -76,6 +92,15 @@ public static void ValidateCreditIsNotADuplicate(this FloatAggregate aggregate, throw new InvalidOperationException($"Float Aggregate Id {aggregate.AggregateId} already has a credit with this information recorded"); } } + + public static void ValidateTransactionIsNotADuplicate(this FloatAggregate aggregate, Guid transactionId) + { + Boolean isDuplicate = aggregate.Transactions.Any(c => c.transactionId == transactionId); + if (isDuplicate == true) + { + throw new InvalidOperationException($"Float Aggregate Id {aggregate.AggregateId} already has a transaction with this Id {transactionId} recorded"); + } + } } public record FloatAggregate : Aggregate @@ -93,8 +118,8 @@ protected override Object GetMetadata() [ExcludeFromCodeCoverage] - public FloatAggregate() - { + public FloatAggregate(){ + this.Transactions = new List<(Guid transactionId, Decimal amount)>(); this.Credits = new List<(DateTime creditPurchasedDate, Decimal amount, Decimal costPrice)>(); } @@ -104,9 +129,11 @@ private FloatAggregate(Guid aggregateId) this.AggregateId = aggregateId; this.Credits = new List<(DateTime creditPurchasedDate, Decimal amount, Decimal costPrice)>(); + this.Transactions = new List<(Guid transactionId, Decimal amount)>(); } internal List<(DateTime creditPurchasedDate, Decimal amount, Decimal costPrice)> Credits; + internal List<(Guid transactionId, Decimal amount)> Transactions; public Boolean IsCreated { get; internal set; } @@ -117,8 +144,10 @@ private FloatAggregate(Guid aggregateId) public DateTime CreatedDateTime { get; internal set; } public Int32 NumberOfCreditPurchases { get; internal set; } + public Int32 NumberOfTransactions { get; internal set; } public Decimal Balance { get; internal set; } public Decimal TotalCreditPurchases { get; internal set; } + public Decimal TotalTransactions { get; internal set; } public Decimal TotalCostPrice { get; internal set; } public Decimal UnitCostPrice { get; internal set; } diff --git a/TransactionProcessor.Reconciliation.DomainEvents/OverallTotalsRecordedEvent.cs b/TransactionProcessor.Reconciliation.DomainEvents/OverallTotalsRecordedEvent.cs deleted file mode 100644 index ed6e6bbf..00000000 --- a/TransactionProcessor.Reconciliation.DomainEvents/OverallTotalsRecordedEvent.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace TransactionProcessor.Reconciliation.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record OverallTotalsRecordedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - /// The transaction count. - /// The transaction value. - public OverallTotalsRecordedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Int32 transactionCount, - Decimal transactionValue) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.TransactionCount = transactionCount; - this.TransactionValue = transactionValue; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction count. - /// - /// - /// The transaction count. - /// - public Int32 TransactionCount { get; init; } - - /// - /// Gets the transaction value. - /// - /// - /// The transaction value. - /// - public Decimal TransactionValue { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationAggregateDomainEvents.cs b/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationAggregateDomainEvents.cs new file mode 100644 index 00000000..2e4de577 --- /dev/null +++ b/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationAggregateDomainEvents.cs @@ -0,0 +1,39 @@ +namespace TransactionProcessor.Reconciliation.DomainEvents +{ + using System; + using System.Diagnostics.CodeAnalysis; + using Newtonsoft.Json; + using Shared.DomainDrivenDesign.EventSourcing; + + [ExcludeFromCodeCoverage] + public record OverallTotalsRecordedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + Int32 TransactionCount, + Decimal TransactionValue) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record ReconciliationHasBeenLocallyAuthorisedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String ResponseCode, + String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record ReconciliationHasBeenLocallyDeclinedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String ResponseCode, + String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record ReconciliationHasCompletedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record ReconciliationHasStartedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + DateTime TransactionDateTime) : DomainEvent(TransactionId, Guid.NewGuid()); +} \ No newline at end of file diff --git a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasBeenLocallyAuthorisedEvent.cs b/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasBeenLocallyAuthorisedEvent.cs deleted file mode 100644 index 2d0d1fec..00000000 --- a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasBeenLocallyAuthorisedEvent.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - - public record ReconciliationHasBeenLocallyAuthorisedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - /// The response code. - /// The response message. - public ReconciliationHasBeenLocallyAuthorisedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String responseCode, - String responseMessage) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.ResponseCode = responseCode; - this.ResponseMessage = responseMessage; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the response code. - /// - /// - /// The response code. - /// - public String ResponseCode { get; init; } - - /// - /// Gets the response message. - /// - /// - /// The response message. - /// - public String ResponseMessage { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasBeenLocallyDeclinedEvent.cs b/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasBeenLocallyDeclinedEvent.cs deleted file mode 100644 index b9ecda5c..00000000 --- a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasBeenLocallyDeclinedEvent.cs +++ /dev/null @@ -1,80 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - public record ReconciliationHasBeenLocallyDeclinedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - /// The response code. - /// The response message. - public ReconciliationHasBeenLocallyDeclinedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String responseCode, - String responseMessage) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.ResponseCode = responseCode; - this.ResponseMessage = responseMessage; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the response code. - /// - /// - /// The response code. - /// - public String ResponseCode { get; init; } - - /// - /// Gets the response message. - /// - /// - /// The response message. - /// - public String ResponseMessage { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasCompletedEvent.cs b/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasCompletedEvent.cs deleted file mode 100644 index 1b142c2e..00000000 --- a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasCompletedEvent.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace TransactionProcessor.Reconciliation.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record ReconciliationHasCompletedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - public ReconciliationHasCompletedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasStartedEvent.cs b/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasStartedEvent.cs deleted file mode 100644 index 7265041e..00000000 --- a/TransactionProcessor.Reconciliation.DomainEvents/ReconciliationHasStartedEvent.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TransactionProcessor.Reconciliation.DomainEvents -{ - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record ReconciliationHasStartedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - /// The transaction date time. - public ReconciliationHasStartedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - DateTime transactionDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.TransactionDateTime = transactionDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction date time. - /// - /// - /// The transaction date time. - /// - public DateTime TransactionDateTime { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} diff --git a/TransactionProcessor.ReconciliationAggregate.Tests/DomainEventTests.cs b/TransactionProcessor.ReconciliationAggregate.Tests/DomainEventTests.cs deleted file mode 100644 index 2b722da8..00000000 --- a/TransactionProcessor.ReconciliationAggregate.Tests/DomainEventTests.cs +++ /dev/null @@ -1,122 +0,0 @@ -namespace TransactionProcessor.ReconciliationAggregate.Tests -{ - using System; - using Reconciliation.DomainEvents; - using Shouldly; - using Testing; - using Transaction.DomainEvents; - using Xunit; - - /// - /// - /// - public class DomainEventTests - { - #region Methods - - /// - /// Overalls the totals recorded event can be created is created. - /// - [Fact] - public void OverallTotalsRecordedEvent_CanBeCreated_IsCreated() - { - OverallTotalsRecordedEvent overallTotalsRecordedEvent = new OverallTotalsRecordedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.ReconciliationTransactionCount, - TestData.ReconciliationTransactionValue); - - overallTotalsRecordedEvent.ShouldNotBeNull(); - overallTotalsRecordedEvent.AggregateId.ShouldBe(TestData.TransactionId); - overallTotalsRecordedEvent.EventId.ShouldNotBe(Guid.Empty); - overallTotalsRecordedEvent.TransactionId.ShouldBe(TestData.TransactionId); - overallTotalsRecordedEvent.EstateId.ShouldBe(TestData.EstateId); - overallTotalsRecordedEvent.MerchantId.ShouldBe(TestData.MerchantId); - overallTotalsRecordedEvent.TransactionCount.ShouldBe(TestData.ReconciliationTransactionCount); - overallTotalsRecordedEvent.TransactionValue.ShouldBe(TestData.ReconciliationTransactionValue); - } - - /// - /// Reconciliations the has been locally authorised event can be created is created. - /// - [Fact] - public void ReconciliationHasBeenLocallyAuthorisedEvent_CanBeCreated_IsCreated() - { - ReconciliationHasBeenLocallyAuthorisedEvent reconciliationHasBeenLocallyAuthorisedEvent = - new ReconciliationHasBeenLocallyAuthorisedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.ResponseCode, - TestData.ResponseMessage); - - reconciliationHasBeenLocallyAuthorisedEvent.ShouldNotBeNull(); - reconciliationHasBeenLocallyAuthorisedEvent.AggregateId.ShouldBe(TestData.TransactionId); - reconciliationHasBeenLocallyAuthorisedEvent.EventId.ShouldNotBe(Guid.Empty); - reconciliationHasBeenLocallyAuthorisedEvent.TransactionId.ShouldBe(TestData.TransactionId); - reconciliationHasBeenLocallyAuthorisedEvent.EstateId.ShouldBe(TestData.EstateId); - reconciliationHasBeenLocallyAuthorisedEvent.MerchantId.ShouldBe(TestData.MerchantId); - reconciliationHasBeenLocallyAuthorisedEvent.ResponseCode.ShouldBe(TestData.ResponseCode); - reconciliationHasBeenLocallyAuthorisedEvent.ResponseMessage.ShouldBe(TestData.ResponseMessage); - } - - /// - /// Reconciliations the has completed event can be created is created. - /// - [Fact] - public void ReconciliationHasCompletedEvent_CanBeCreated_IsCreated() - { - ReconciliationHasCompletedEvent reconciliationHasCompletedEvent = - new ReconciliationHasCompletedEvent(TestData.TransactionId, TestData.EstateId, TestData.MerchantId); - - reconciliationHasCompletedEvent.ShouldNotBeNull(); - reconciliationHasCompletedEvent.AggregateId.ShouldBe(TestData.TransactionId); - reconciliationHasCompletedEvent.EventId.ShouldNotBe(Guid.Empty); - reconciliationHasCompletedEvent.TransactionId.ShouldBe(TestData.TransactionId); - reconciliationHasCompletedEvent.EstateId.ShouldBe(TestData.EstateId); - reconciliationHasCompletedEvent.MerchantId.ShouldBe(TestData.MerchantId); - } - - /// - /// Reconciliations the has started event can be created is created. - /// - [Fact] - public void ReconciliationHasStartedEvent_CanBeCreated_IsCreated() - { - ReconciliationHasStartedEvent reconciliationHasStartedEvent = new ReconciliationHasStartedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.TransactionDateTime); - reconciliationHasStartedEvent.ShouldNotBeNull(); - reconciliationHasStartedEvent.AggregateId.ShouldBe(TestData.TransactionId); - reconciliationHasStartedEvent.EventId.ShouldNotBe(Guid.Empty); - reconciliationHasStartedEvent.TransactionId.ShouldBe(TestData.TransactionId); - reconciliationHasStartedEvent.EstateId.ShouldBe(TestData.EstateId); - reconciliationHasStartedEvent.MerchantId.ShouldBe(TestData.MerchantId); - reconciliationHasStartedEvent.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - } - - /// - /// Transactions the has been locally declined event can be created is created. - /// - [Fact] - public void TransactionHasBeenLocallyDeclinedEvent_CanBeCreated_IsCreated() - { - ReconciliationHasBeenLocallyDeclinedEvent reconciliationHasBeenLocallyDeclinedEvent = new ReconciliationHasBeenLocallyDeclinedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.DeclinedResponseCode, - TestData.DeclinedResponseMessage); - - reconciliationHasBeenLocallyDeclinedEvent.ShouldNotBeNull(); - reconciliationHasBeenLocallyDeclinedEvent.AggregateId.ShouldBe(TestData.TransactionId); - reconciliationHasBeenLocallyDeclinedEvent.EventId.ShouldNotBe(Guid.Empty); - reconciliationHasBeenLocallyDeclinedEvent.TransactionId.ShouldBe(TestData.TransactionId); - reconciliationHasBeenLocallyDeclinedEvent.EstateId.ShouldBe(TestData.EstateId); - reconciliationHasBeenLocallyDeclinedEvent.MerchantId.ShouldBe(TestData.MerchantId); - reconciliationHasBeenLocallyDeclinedEvent.ResponseCode.ShouldBe(TestData.DeclinedResponseCode); - reconciliationHasBeenLocallyDeclinedEvent.ResponseMessage.ShouldBe(TestData.DeclinedResponseMessage); - } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs b/TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs index 3cf551da..d9e5e77b 100644 --- a/TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs +++ b/TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs @@ -8,7 +8,6 @@ namespace TransactionProcessor.ReconciliationAggregate using Shared.EventStore.Aggregate; using Shared.EventStore.EventStore; using Shared.General; - using Transaction.DomainEvents; public static class ReconciliationAggregateExtensions{ public static void PlayEvent(this ReconciliationAggregate aggregate, ReconciliationHasStartedEvent domainEvent) diff --git a/TransactionProcessor.Settlement.DomainEvents/MerchantFeeAddedToPendingSettlementEvent.cs b/TransactionProcessor.Settlement.DomainEvents/MerchantFeeAddedToPendingSettlementEvent.cs deleted file mode 100644 index 959b1114..00000000 --- a/TransactionProcessor.Settlement.DomainEvents/MerchantFeeAddedToPendingSettlementEvent.cs +++ /dev/null @@ -1,99 +0,0 @@ -namespace TransactionProcessor.Settlement.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record MerchantFeeAddedPendingSettlementEvent : DomainEvent - { - #region Properties - - /// - /// Gets the calculated value. - /// - /// - /// The calculated value. - /// - public Decimal CalculatedValue { get; init; } - - /// - /// Gets or sets the fee calculated date time. - /// - /// - /// The fee calculated date time. - /// - public DateTime FeeCalculatedDateTime { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the type of the fee calculation. - /// - /// - /// The type of the fee calculation. - /// - public Int32 FeeCalculationType { get; init; } - - /// - /// Gets the fee identifier. - /// - /// - /// The fee identifier. - /// - public Guid FeeId { get; init; } - - /// - /// Gets the fee value. - /// - /// - /// The fee value. - /// - public Decimal FeeValue { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - public Guid SettlementId { get; init; } - - #endregion - - public MerchantFeeAddedPendingSettlementEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Guid transactionId, - Decimal calculatedValue, - Int32 feeCalculationType, - Guid feeId, - Decimal feeValue, - DateTime feeCalculatedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.MerchantId = merchantId; - this.TransactionId = transactionId; - this.CalculatedValue = calculatedValue; - this.FeeCalculationType = feeCalculationType; - this.FeeId = feeId; - this.FeeValue = feeValue; - this.FeeCalculatedDateTime = feeCalculatedDateTime; - this.SettlementId = aggregateId; - } - } -} \ No newline at end of file diff --git a/TransactionProcessor.Settlement.DomainEvents/MerchantFeeSettledEvent.cs b/TransactionProcessor.Settlement.DomainEvents/MerchantFeeSettledEvent.cs deleted file mode 100644 index b442c4b3..00000000 --- a/TransactionProcessor.Settlement.DomainEvents/MerchantFeeSettledEvent.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionProcessor.Settlement.DomainEvents -{ - using Shared.DomainDrivenDesign.EventSourcing; - - public record MerchantFeeSettledEvent : DomainEvent - { - #region Properties - - public Decimal CalculatedValue { get; init; } - - public DateTime FeeCalculatedDateTime { get; init; } - - public DateTime SettledDateTime{ get; init; } - - public Guid EstateId { get; init; } - - public Int32 FeeCalculationType { get; init; } - - public Guid FeeId { get; init; } - - public Decimal FeeValue { get; init; } - - public Guid MerchantId { get; init; } - - public Guid TransactionId { get; init; } - - public Guid SettlementId { get; init; } - - #endregion - - public MerchantFeeSettledEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Guid transactionId, - Decimal calculatedValue, - Int32 feeCalculationType, - Guid feeId, - Decimal feeValue, - DateTime feeCalculatedDateTime, - DateTime settledDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.MerchantId = merchantId; - this.TransactionId = transactionId; - this.CalculatedValue = calculatedValue; - this.FeeCalculationType = feeCalculationType; - this.FeeId = feeId; - this.FeeValue = feeValue; - this.FeeCalculatedDateTime = feeCalculatedDateTime; - this.SettledDateTime = settledDateTime; - this.SettlementId = aggregateId; - } - } -} \ No newline at end of file diff --git a/TransactionProcessor.Settlement.DomainEvents/SettlementAggregateDomainEvents.cs b/TransactionProcessor.Settlement.DomainEvents/SettlementAggregateDomainEvents.cs new file mode 100644 index 00000000..d7dba482 --- /dev/null +++ b/TransactionProcessor.Settlement.DomainEvents/SettlementAggregateDomainEvents.cs @@ -0,0 +1,44 @@ +namespace TransactionProcessor.Settlement.DomainEvents{ + using System; + using System.Diagnostics.CodeAnalysis; + using Shared.DomainDrivenDesign.EventSourcing; + + [ExcludeFromCodeCoverage] + public record MerchantFeeAddedPendingSettlementEvent(Guid SettlementId, + Guid EstateId, + Guid MerchantId, + Guid TransactionId, + Decimal CalculatedValue, + Int32 FeeCalculationType, + Guid FeeId, + Decimal FeeValue, + DateTime FeeCalculatedDateTime) : DomainEvent(SettlementId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record MerchantFeeSettledEvent(Guid SettlementId, + Guid EstateId, + Guid MerchantId, + Guid TransactionId, + Decimal CalculatedValue, + Int32 FeeCalculationType, + Guid FeeId, + Decimal FeeValue, + DateTime FeeCalculatedDateTime, + DateTime SettledDateTime) : DomainEvent(SettlementId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record SettlementCompletedEvent(Guid SettlementId, + Guid EstateId) : DomainEvent(SettlementId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record SettlementCreatedForDateEvent(Guid SettlementId, + Guid EstateId, + Guid MerchantId, + DateTime SettlementDate) : DomainEvent(SettlementId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record SettlementProcessingStartedEvent(Guid SettlementId, + Guid EstateId, + Guid MerchantId, + DateTime ProcessingStartedDateTime) : DomainEvent(SettlementId, Guid.NewGuid()); +} \ No newline at end of file diff --git a/TransactionProcessor.Settlement.DomainEvents/SettlementCompletedEvent.cs b/TransactionProcessor.Settlement.DomainEvents/SettlementCompletedEvent.cs deleted file mode 100644 index b978383b..00000000 --- a/TransactionProcessor.Settlement.DomainEvents/SettlementCompletedEvent.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace TransactionProcessor.Settlement.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record SettlementCompletedEvent : DomainEvent - { - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - public Guid SettlementId { get; init; } - - #endregion - - public SettlementCompletedEvent(Guid aggregateId, - Guid estateId) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.SettlementId = aggregateId; - } - } -} \ No newline at end of file diff --git a/TransactionProcessor.Settlement.DomainEvents/SettlementCreatedForDateEvent.cs b/TransactionProcessor.Settlement.DomainEvents/SettlementCreatedForDateEvent.cs deleted file mode 100644 index 446eebe6..00000000 --- a/TransactionProcessor.Settlement.DomainEvents/SettlementCreatedForDateEvent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TransactionProcessor.Settlement.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record SettlementCreatedForDateEvent(Guid SettlementId, - Guid EstateId, - Guid MerchantId, - DateTime SettlementDate) : DomainEvent(SettlementId, Guid.NewGuid()); -} \ No newline at end of file diff --git a/TransactionProcessor.Settlement.DomainEvents/SettlementProcessingStartedEvent.cs b/TransactionProcessor.Settlement.DomainEvents/SettlementProcessingStartedEvent.cs deleted file mode 100644 index 6e7fc762..00000000 --- a/TransactionProcessor.Settlement.DomainEvents/SettlementProcessingStartedEvent.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace TransactionProcessor.Settlement.DomainEvents; - -using System; -using Shared.DomainDrivenDesign.EventSourcing; - -public record SettlementProcessingStartedEvent(Guid SettlementId, - Guid EstateId, - Guid MerchantId, - DateTime ProcessingStartedDateTime) : DomainEvent(SettlementId, Guid.NewGuid()); \ No newline at end of file diff --git a/TransactionProcessor.SettlementAggregates.Tests/DomainEventTests.cs b/TransactionProcessor.SettlementAggregates.Tests/DomainEventTests.cs deleted file mode 100644 index 35a4ddc6..00000000 --- a/TransactionProcessor.SettlementAggregates.Tests/DomainEventTests.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionProcessor.SettlementAggregates.Tests -{ - using Models; - using Settlement.DomainEvents; - using Shouldly; - using Testing; - using Xunit; - - public class DomainEventTests - { - [Fact] - public void SettlementCreatedForDateEvent_CanBeCreated_IsCreated() - { - SettlementCreatedForDateEvent settlementCreatedForDateEvent = - new SettlementCreatedForDateEvent(TestData.SettlementAggregateId, TestData.EstateId,TestData.MerchantId, TestData.SettlementDate); - - settlementCreatedForDateEvent.ShouldNotBeNull(); - settlementCreatedForDateEvent.AggregateId.ShouldBe(TestData.SettlementAggregateId); - settlementCreatedForDateEvent.EventId.ShouldNotBe(Guid.Empty); - settlementCreatedForDateEvent.SettlementId.ShouldBe(TestData.SettlementAggregateId); - settlementCreatedForDateEvent.EstateId.ShouldBe(TestData.EstateId); - settlementCreatedForDateEvent.MerchantId.ShouldBe(TestData.MerchantId); - settlementCreatedForDateEvent.SettlementDate.ShouldBe(TestData.SettlementDate); - } - - [Fact] - public void MerchantFeeAddedPendingSettlementEvent_CanBeCreated_IsCreated() - { - MerchantFeeAddedPendingSettlementEvent merchantFeeAddedPendingSettlementEvent = - new MerchantFeeAddedPendingSettlementEvent(TestData.SettlementAggregateId, - TestData.EstateId, - TestData.MerchantId, - TestData.TransactionId, - TestData.CalculatedFeeValue, - (Int32)CalculationType.Fixed, - TestData.TransactionFeeId, - TestData.TransactionFeeValue, - TestData.TransactionFeeCalculateDateTime); - - merchantFeeAddedPendingSettlementEvent.ShouldNotBeNull(); - merchantFeeAddedPendingSettlementEvent.AggregateId.ShouldBe(TestData.SettlementAggregateId); - merchantFeeAddedPendingSettlementEvent.EventId.ShouldNotBe(Guid.Empty); - merchantFeeAddedPendingSettlementEvent.SettlementId.ShouldBe(TestData.SettlementAggregateId); - merchantFeeAddedPendingSettlementEvent.EstateId.ShouldBe(TestData.EstateId); - merchantFeeAddedPendingSettlementEvent.MerchantId.ShouldBe(TestData.MerchantId); - merchantFeeAddedPendingSettlementEvent.TransactionId.ShouldBe(TestData.TransactionId); - merchantFeeAddedPendingSettlementEvent.CalculatedValue.ShouldBe(TestData.CalculatedFeeValue); - merchantFeeAddedPendingSettlementEvent.FeeCalculationType.ShouldBe((Int32)CalculationType.Fixed); - merchantFeeAddedPendingSettlementEvent.FeeId.ShouldBe(TestData.TransactionFeeId); - merchantFeeAddedPendingSettlementEvent.FeeValue.ShouldBe(TestData.TransactionFeeValue); - merchantFeeAddedPendingSettlementEvent.FeeCalculatedDateTime.ShouldBe(TestData.TransactionFeeCalculateDateTime); - } - - [Fact] - public void MerchantFeeSettledEvent_CanBeCreated_IsCreated() - { - MerchantFeeSettledEvent merchantFeeSettledEvent = - new MerchantFeeSettledEvent(TestData.SettlementAggregateId, TestData.EstateId, TestData.MerchantId, - TestData.TransactionId, TestData.CalculatedFeeValue, - (Int32)CalculationType.Fixed, - TestData.TransactionFeeId, - TestData.TransactionFeeValue, - TestData.TransactionFeeCalculateDateTime, - TestData.SettlementDate); - - merchantFeeSettledEvent.ShouldNotBeNull(); - merchantFeeSettledEvent.AggregateId.ShouldBe(TestData.SettlementAggregateId); - merchantFeeSettledEvent.EventId.ShouldNotBe(Guid.Empty); - merchantFeeSettledEvent.SettlementId.ShouldBe(TestData.SettlementAggregateId); - merchantFeeSettledEvent.EstateId.ShouldBe(TestData.EstateId); - merchantFeeSettledEvent.MerchantId.ShouldBe(TestData.MerchantId); - merchantFeeSettledEvent.TransactionId.ShouldBe(TestData.TransactionId); - merchantFeeSettledEvent.CalculatedValue.ShouldBe(TestData.CalculatedFeeValue); - merchantFeeSettledEvent.FeeCalculationType.ShouldBe((Int32)CalculationType.Fixed); - merchantFeeSettledEvent.FeeId.ShouldBe(TestData.TransactionFeeId); - merchantFeeSettledEvent.FeeValue.ShouldBe(TestData.TransactionFeeValue); - merchantFeeSettledEvent.FeeCalculatedDateTime.ShouldBe(TestData.TransactionFeeCalculateDateTime); - merchantFeeSettledEvent.SettledDateTime.ShouldBe(TestData.SettlementDate); - } - - [Fact] - public void SettlementCompletedEvent_CanBeCreated_IsCreated() - { - SettlementCompletedEvent settlementCompletedEvent = - new SettlementCompletedEvent(TestData.SettlementAggregateId, TestData.EstateId); - - settlementCompletedEvent.ShouldNotBeNull(); - settlementCompletedEvent.AggregateId.ShouldBe(TestData.SettlementAggregateId); - settlementCompletedEvent.EventId.ShouldNotBe(Guid.Empty); - settlementCompletedEvent.SettlementId.ShouldBe(TestData.SettlementAggregateId); - settlementCompletedEvent.EstateId.ShouldBe(TestData.EstateId); - } - - [Fact] - public void SettlementProcessingStartedEvent_CanBeCreated_IsCreated() - { - SettlementProcessingStartedEvent settlementProcessingStartedEvent = new SettlementProcessingStartedEvent(TestData.SettlementAggregateId, - TestData.EstateId, - TestData.MerchantId, - TestData.SettlementProcessingStartedDateTime); - - settlementProcessingStartedEvent.ShouldNotBeNull(); - settlementProcessingStartedEvent.AggregateId.ShouldBe(TestData.SettlementAggregateId); - settlementProcessingStartedEvent.EventId.ShouldNotBe(Guid.Empty); - settlementProcessingStartedEvent.SettlementId.ShouldBe(TestData.SettlementAggregateId); - settlementProcessingStartedEvent.EstateId.ShouldBe(TestData.EstateId); - settlementProcessingStartedEvent.MerchantId.ShouldBe(TestData.MerchantId); - settlementProcessingStartedEvent.ProcessingStartedDateTime.ShouldBe(TestData.SettlementProcessingStartedDateTime); - - } - } -} diff --git a/TransactionProcessor.Testing/TestData.cs b/TransactionProcessor.Testing/TestData.cs index d300a345..958ba0d1 100644 --- a/TransactionProcessor.Testing/TestData.cs +++ b/TransactionProcessor.Testing/TestData.cs @@ -17,6 +17,7 @@ using ReconciliationAggregate; using SecurityService.DataTransferObjects.Responses; using SettlementAggregates; + using Shared.DomainDrivenDesign.EventSourcing; using Transaction.DomainEvents; using TransactionAggregate; using TransactionProcessor.Voucher.DomainEvents; @@ -1278,6 +1279,13 @@ public static SettlementAggregate GetSettlementAggregateWithNotAllFeesSettled(In public static Decimal UnitCostPrice = 0.9m; public static Decimal TotalCostPrice = 9.0m; + public static TransactionCostInformationRecordedEvent TransactionCostInformationRecordedEvent => + new TransactionCostInformationRecordedEvent(TestData.TransactionId, + TestData.EstateId, + TestData.MerchantId, + TestData.UnitCostPrice, + TestData.TotalCostPrice); + public static RecordCreditPurchaseForFloatRequest RecordCreditPurchaseForFloatRequest => RecordCreditPurchaseForFloatRequest.Create(TestData.EstateId, TestData.FloatAggregateId, TestData.FloatCreditAmount, TestData.FloatCreditCostPrice, TestData.CreditPurchasedDateTime); public static CreateFloatForContractProductRequest CreateFloatForContractProductRequest => CreateFloatForContractProductRequest.Create(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); diff --git a/TransactionProcessor.Transaction.DomainEvents/AdditionalRequestDataRecordedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/AdditionalRequestDataRecordedEvent.cs deleted file mode 100644 index 1241b97c..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/AdditionalRequestDataRecordedEvent.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record AdditionalRequestDataRecordedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - /// The operator identifier. - /// The additional transaction request metadata. - public AdditionalRequestDataRecordedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String operatorIdentifier, - Dictionary additionalTransactionRequestMetadata) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.OperatorIdentifier = operatorIdentifier; - this.AdditionalTransactionRequestMetadata = additionalTransactionRequestMetadata; - } - - #endregion - - #region Properties - - /// - /// Gets the additional transaction request metadata. - /// - /// - /// The additional transaction request metadata. - /// - public Dictionary AdditionalTransactionRequestMetadata { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the operator identifier. - /// - /// - /// The operator identifier. - /// - public String OperatorIdentifier { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/AdditionalResponseDataRecordedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/AdditionalResponseDataRecordedEvent.cs deleted file mode 100644 index 5dd9aa7f..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/AdditionalResponseDataRecordedEvent.cs +++ /dev/null @@ -1,85 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record AdditionalResponseDataRecordedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - /// The operator identifier. - /// The additional transaction response metadata. - public AdditionalResponseDataRecordedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String operatorIdentifier, - Dictionary additionalTransactionResponseMetadata) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.OperatorIdentifier = operatorIdentifier; - this.AdditionalTransactionResponseMetadata = additionalTransactionResponseMetadata; - } - - #endregion - - #region Properties - - /// - /// Gets the additional transaction request metadata. - /// - /// - /// The additional transaction request metadata. - /// - public Dictionary AdditionalTransactionResponseMetadata { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the operator identifier. - /// - /// - /// The operator identifier. - /// - public String OperatorIdentifier { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/CustomerEmailReceiptRequestedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/CustomerEmailReceiptRequestedEvent.cs deleted file mode 100644 index e16b19ec..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/CustomerEmailReceiptRequestedEvent.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record CustomerEmailReceiptRequestedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The event identifier. - /// The estate identifier. - /// The merchant identifier. - /// The customer email address. - public CustomerEmailReceiptRequestedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String customerEmailAddress) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.CustomerEmailAddress = customerEmailAddress; - } - - #endregion - - #region Properties - - /// - /// Gets the customer email address. - /// - /// - /// The customer email address. - /// - public String CustomerEmailAddress { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/CustomerEmailReceiptResendRequestedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/CustomerEmailReceiptResendRequestedEvent.cs deleted file mode 100644 index 5768a8bf..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/CustomerEmailReceiptResendRequestedEvent.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents; - -using System; -using Shared.DomainDrivenDesign.EventSourcing; - -public record CustomerEmailReceiptResendRequestedEvent : DomainEvent -{ - #region Constructors - - public CustomerEmailReceiptResendRequestedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/MerchantFeeAddedToTransactionEvent.cs b/TransactionProcessor.Transaction.DomainEvents/MerchantFeeAddedToTransactionEvent.cs deleted file mode 100644 index 718c90d9..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/MerchantFeeAddedToTransactionEvent.cs +++ /dev/null @@ -1,114 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record SettledMerchantFeeAddedToTransactionEvent : DomainEvent - { - #region Constructors - - public SettledMerchantFeeAddedToTransactionEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Decimal calculatedValue, - Int32 feeCalculationType, - Guid feeId, - Decimal feeValue, - DateTime feeCalculatedDateTime, - DateTime settledDateTime, - Guid settlementId) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.CalculatedValue = calculatedValue; - this.FeeCalculationType = feeCalculationType; - this.FeeId = feeId; - this.FeeValue = feeValue; - this.FeeCalculatedDateTime = feeCalculatedDateTime; - this.SettledDateTime = settledDateTime; - this.SettlementId = settlementId; - } - - #endregion - - #region Properties - - public Decimal CalculatedValue { get; init; } - - public DateTime FeeCalculatedDateTime { get; init; } - - public DateTime SettledDateTime { get; init; } - - public Guid SettlementId{ get; init; } - - public Guid EstateId { get; init; } - - public Int32 FeeCalculationType { get; init; } - - public Guid FeeId { get; init; } - - public Decimal FeeValue { get; init; } - - public Guid MerchantId { get; init; } - - public Guid TransactionId { get; init; } - - #endregion - } - - - public record MerchantFeePendingSettlementAddedToTransactionEvent : DomainEvent - { - #region Constructors - - public MerchantFeePendingSettlementAddedToTransactionEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Decimal calculatedValue, - Int32 feeCalculationType, - Guid feeId, - Decimal feeValue, - DateTime feeCalculatedDateTime, - DateTime settlementDueDate) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.CalculatedValue = calculatedValue; - this.FeeCalculationType = feeCalculationType; - this.FeeId = feeId; - this.FeeValue = feeValue; - this.FeeCalculatedDateTime = feeCalculatedDateTime; - this.SettlementDueDate = settlementDueDate; - } - - #endregion - - #region Properties - - public Decimal CalculatedValue { get; init; } - - public DateTime FeeCalculatedDateTime { get; init; } - - public DateTime SettlementDueDate { get; init; } - - public Guid EstateId { get; init; } - - public Int32 FeeCalculationType { get; init; } - - public Guid FeeId { get; init; } - - public Decimal FeeValue { get; init; } - - public Guid MerchantId { get; init; } - - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/ProductDetailsAddedToTransactionEvent.cs b/TransactionProcessor.Transaction.DomainEvents/ProductDetailsAddedToTransactionEvent.cs deleted file mode 100644 index cdfd913f..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/ProductDetailsAddedToTransactionEvent.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record ProductDetailsAddedToTransactionEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The contract identifier. - /// The product identifier. - public ProductDetailsAddedToTransactionEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Guid contractId, - Guid productId) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.ContractId = contractId; - this.ProductId = productId; - } - - #endregion - - #region Properties - - /// - /// Gets the contract identifier. - /// - /// - /// The contract identifier. - /// - public Guid ContractId { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the product identifier. - /// - /// - /// The product identifier. - /// - public Guid ProductId { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/ServiceProviderFeeAddedToTransactionEvent.cs b/TransactionProcessor.Transaction.DomainEvents/ServiceProviderFeeAddedToTransactionEvent.cs deleted file mode 100644 index 099dca9c..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/ServiceProviderFeeAddedToTransactionEvent.cs +++ /dev/null @@ -1,116 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record ServiceProviderFeeAddedToTransactionEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The calculated value. - /// Type of the fee calculation. - /// The fee identifier. - /// The fee value. - /// The fee calculated date time. - public ServiceProviderFeeAddedToTransactionEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Decimal calculatedValue, - Int32 feeCalculationType, - Guid feeId, - Decimal feeValue, - DateTime feeCalculatedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.CalculatedValue = calculatedValue; - this.FeeCalculationType = feeCalculationType; - this.FeeId = feeId; - this.FeeValue = feeValue; - this.FeeCalculatedDateTime = feeCalculatedDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets the calculated value. - /// - /// - /// The calculated value. - /// - public Decimal CalculatedValue { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the type of the fee calculation. - /// - /// - /// The type of the fee calculation. - /// - public Int32 FeeCalculationType { get; init; } - - /// - /// Gets the fee identifier. - /// - /// - /// The fee identifier. - /// - public Guid FeeId { get; init; } - - /// - /// Gets the fee value. - /// - /// - /// The fee value. - /// - public Decimal FeeValue { get; init; } - - /// - /// Gets or sets the fee calculated date time. - /// - /// - /// The fee calculated date time. - /// - public DateTime FeeCalculatedDateTime { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionAggregateDomainEvents.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionAggregateDomainEvents.cs new file mode 100644 index 00000000..850cd2d2 --- /dev/null +++ b/TransactionProcessor.Transaction.DomainEvents/TransactionAggregateDomainEvents.cs @@ -0,0 +1,142 @@ +namespace TransactionProcessor.Transaction.DomainEvents{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using Shared.DomainDrivenDesign.EventSourcing; + + [ExcludeFromCodeCoverage] + public record CustomerEmailReceiptResendRequestedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record CustomerEmailReceiptRequestedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String CustomerEmailAddress) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record AdditionalRequestDataRecordedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String OperatorIdentifier, + Dictionary AdditionalTransactionRequestMetadata) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record AdditionalResponseDataRecordedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String OperatorIdentifier, + Dictionary AdditionalTransactionResponseMetadata) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record SettledMerchantFeeAddedToTransactionEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + Decimal CalculatedValue, + Int32 FeeCalculationType, + Guid FeeId, + Decimal FeeValue, + DateTime FeeCalculatedDateTime, + DateTime SettledDateTime, + Guid SettlementId) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record MerchantFeePendingSettlementAddedToTransactionEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + Decimal CalculatedValue, + Int32 FeeCalculationType, + Guid FeeId, + Decimal FeeValue, + DateTime FeeCalculatedDateTime, + DateTime SettlementDueDate) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record ProductDetailsAddedToTransactionEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + Guid ContractId, + Guid ProductId) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record ServiceProviderFeeAddedToTransactionEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + Decimal CalculatedValue, + Int32 FeeCalculationType, + Guid FeeId, + Decimal FeeValue, + DateTime FeeCalculatedDateTime) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionAuthorisedByOperatorEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String OperatorIdentifier, + String AuthorisationCode, + String OperatorResponseCode, + String OperatorResponseMessage, + String OperatorTransactionId, + String ResponseCode, + String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionCostInformationRecordedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + Decimal? UnitCostValue, + Decimal? TotalCostValue) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionDeclinedByOperatorEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String OperatorIdentifier, + String OperatorResponseCode, + String OperatorResponseMessage, + String ResponseCode, + String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionHasBeenCompletedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String ResponseCode, + String ResponseMessage, + Boolean IsAuthorised, + DateTime CompletedDateTime, + Decimal? TransactionAmount) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionHasBeenLocallyAuthorisedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String AuthorisationCode, + String ResponseCode, + String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionHasBeenLocallyDeclinedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + String ResponseCode, + String ResponseMessage) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionHasStartedEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + DateTime TransactionDateTime, + String TransactionNumber, + String TransactionType, + String TransactionReference, + String DeviceIdentifier, + Decimal? TransactionAmount) : DomainEvent(TransactionId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record TransactionSourceAddedToTransactionEvent(Guid TransactionId, + Guid EstateId, + Guid MerchantId, + Int32 TransactionSource) : DomainEvent(TransactionId, Guid.NewGuid()); +} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionAuthorisedByOperatorEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionAuthorisedByOperatorEvent.cs deleted file mode 100644 index 4e2c7b6d..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionAuthorisedByOperatorEvent.cs +++ /dev/null @@ -1,134 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - public record TransactionAuthorisedByOperatorEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The operator identifier. - /// The authorisation code. - /// The operator response code. - /// The operator response message. - /// The operator transaction identifier. - /// The response code. - /// The response message. - public TransactionAuthorisedByOperatorEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String operatorIdentifier, - String authorisationCode, - String operatorResponseCode, - String operatorResponseMessage, - String operatorTransactionId, - String responseCode, - String responseMessage) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.OperatorIdentifier = operatorIdentifier; - this.AuthorisationCode = authorisationCode; - this.OperatorResponseCode = operatorResponseCode; - this.OperatorResponseMessage = operatorResponseMessage; - this.OperatorTransactionId = operatorTransactionId; - this.ResponseCode = responseCode; - this.ResponseMessage = responseMessage; - } - - #endregion - - #region Properties - - /// - /// Gets the authorisation code. - /// - /// - /// The authorisation code. - /// - public String AuthorisationCode { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the operator identifier. - /// - /// - /// The operator identifier. - /// - public String OperatorIdentifier { get; init; } - - /// - /// Gets the operator response code. - /// - /// - /// The operator response code. - /// - public String OperatorResponseCode { get; init; } - - /// - /// Gets the operator response message. - /// - /// - /// The operator response message. - /// - public String OperatorResponseMessage { get; init; } - - /// - /// Gets or sets the operator transaction identifier. - /// - /// - /// The operator transaction identifier. - /// - public String OperatorTransactionId { get; init; } - - /// - /// Gets the response code. - /// - /// - /// The response code. - /// - public String ResponseCode { get; init; } - - /// - /// Gets the response message. - /// - /// - /// The response message. - /// - public String ResponseMessage { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionCostInformationRecordedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionCostInformationRecordedEvent.cs deleted file mode 100644 index 5a38e374..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionCostInformationRecordedEvent.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Shared.DomainDrivenDesign.EventSourcing; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TransactionProcessor.Transaction.DomainEvents -{ - public record TransactionCostInformationRecordedEvent : DomainEvent - { - #region Constructors - - public TransactionCostInformationRecordedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Decimal? unitCostValue, - Decimal? totalCostValue) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.UnitCostValue = unitCostValue; - this.TotalCostValue = totalCostValue; - } - - #endregion - - #region Properties - - public Guid EstateId { get; init; } - - public Guid MerchantId { get; init; } - - public Guid TransactionId { get; init; } - - public Decimal? UnitCostValue { get; init; } - - public Decimal? TotalCostValue { get; init; } - - #endregion - } -} diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionDeclinedByOperatorEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionDeclinedByOperatorEvent.cs deleted file mode 100644 index 9bb46116..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionDeclinedByOperatorEvent.cs +++ /dev/null @@ -1,113 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - public record TransactionDeclinedByOperatorEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The operator identifier. - /// The operator response code. - /// The operator response message. - /// The response code. - /// The response message. - public TransactionDeclinedByOperatorEvent(Guid aggregateId, - - Guid estateId, - Guid merchantId, - String operatorIdentifier, - String operatorResponseCode, - String operatorResponseMessage, - String responseCode, - String responseMessage) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.OperatorIdentifier = operatorIdentifier; - this.OperatorResponseCode = operatorResponseCode; - this.OperatorResponseMessage = operatorResponseMessage; - this.ResponseCode = responseCode; - this.ResponseMessage = responseMessage; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the operator identifier. - /// - /// - /// The operator identifier. - /// - public String OperatorIdentifier { get; init; } - - /// - /// Gets the operator response code. - /// - /// - /// The operator response code. - /// - public String OperatorResponseCode { get; init; } - - /// - /// Gets the operator response message. - /// - /// - /// The operator response message. - /// - public String OperatorResponseMessage { get; init; } - - /// - /// Gets the response code. - /// - /// - /// The response code. - /// - public String ResponseCode { get; init; } - - /// - /// Gets the response message. - /// - /// - /// The response message. - /// - public String ResponseMessage { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenCompletedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenCompletedEvent.cs deleted file mode 100644 index 44c84a9e..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenCompletedEvent.cs +++ /dev/null @@ -1,117 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record TransactionHasBeenCompletedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The response code. - /// The response message. - /// if set to true [is authorised]. - /// The completed date time. - /// The transaction amount. - public TransactionHasBeenCompletedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String responseCode, - String responseMessage, - Boolean isAuthorised, - DateTime completedDateTime, - Decimal? transactionAmount) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.ResponseCode = responseCode; - this.ResponseMessage = responseMessage; - this.IsAuthorised = isAuthorised; - this.CompletedDateTime = completedDateTime; - this.TransactionAmount = transactionAmount; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the completed date time. - /// - /// - /// The completed date time. - /// - public DateTime CompletedDateTime { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets a value indicating whether this instance is authorised. - /// - /// - /// true if this instance is authorised; otherwise, false. - /// - public Boolean IsAuthorised { get; init; } - - /// - /// Gets the transaction amount. - /// - /// - /// The transaction amount. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public Decimal? TransactionAmount { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the response code. - /// - /// - /// The response code. - /// - public String ResponseCode { get; init; } - - /// - /// Gets the response message. - /// - /// - /// The response message. - /// - public String ResponseMessage { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenLocallyAuthorisedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenLocallyAuthorisedEvent.cs deleted file mode 100644 index d5bba796..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenLocallyAuthorisedEvent.cs +++ /dev/null @@ -1,94 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record TransactionHasBeenLocallyAuthorisedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The authorisation code. - /// The response code. - /// The response message. - public TransactionHasBeenLocallyAuthorisedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String authorisationCode, - String responseCode, - String responseMessage) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.AuthorisationCode = authorisationCode; - this.ResponseCode = responseCode; - this.ResponseMessage = responseMessage; - } - - #endregion - - #region Properties - - /// - /// Gets the authorisation code. - /// - /// - /// The authorisation code. - /// - public String AuthorisationCode { get; init; } - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the response code. - /// - /// - /// The response code. - /// - public String ResponseCode { get; init; } - - /// - /// Gets the response message. - /// - /// - /// The response message. - /// - public String ResponseMessage { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenLocallyDeclinedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenLocallyDeclinedEvent.cs deleted file mode 100644 index 952dc9c7..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionHasBeenLocallyDeclinedEvent.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - public record TransactionHasBeenLocallyDeclinedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The response code. - /// The response message. - public TransactionHasBeenLocallyDeclinedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - String responseCode, - String responseMessage) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.ResponseCode = responseCode; - this.ResponseMessage = responseMessage; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the response code. - /// - /// - /// The response code. - /// - public String ResponseCode { get; init; } - - /// - /// Gets the response message. - /// - /// - /// The response message. - /// - public String ResponseMessage { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionHasStartedEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionHasStartedEvent.cs deleted file mode 100644 index f6184a1c..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionHasStartedEvent.cs +++ /dev/null @@ -1,128 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents -{ - using System; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - /// - /// - /// - /// - public record TransactionHasStartedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The merchant identifier. - /// The transaction date time. - /// The transaction number. - /// Type of the transaction. - /// The transaction reference. - /// The device identifier. - /// The transaction amount. - public TransactionHasStartedEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - DateTime transactionDateTime, - String transactionNumber, - String transactionType, - String transactionReference, - String deviceIdentifier, - Decimal? transactionAmount) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.TransactionDateTime = transactionDateTime; - this.TransactionNumber = transactionNumber; - this.TransactionType = transactionType; - this.TransactionReference = transactionReference; - this.DeviceIdentifier = deviceIdentifier; - this.TransactionAmount = transactionAmount; - } - - #endregion - - #region Properties - - /// - /// Gets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets the device identifier. - /// - /// - /// The device identifier. - /// - public String DeviceIdentifier { get; init; } - - /// - /// Gets the transaction amount. - /// - /// - /// The transaction amount. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public Decimal? TransactionAmount { get; init; } - - /// - /// Gets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets the transaction date time. - /// - /// - /// The transaction date time. - /// - public DateTime TransactionDateTime { get; init; } - - /// - /// Gets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - - /// - /// Gets the transaction number. - /// - /// - /// The transaction number. - /// - public String TransactionNumber { get; init; } - - /// - /// Gets the type of the transaction. - /// - /// - /// The type of the transaction. - /// - public String TransactionType { get; init; } - - /// - /// Gets or sets the transaction reference. - /// - /// - /// The transaction reference. - /// - public String TransactionReference { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.Transaction.DomainEvents/TransactionSourceAddedToTransactionEvent.cs b/TransactionProcessor.Transaction.DomainEvents/TransactionSourceAddedToTransactionEvent.cs deleted file mode 100644 index 8a4f5826..00000000 --- a/TransactionProcessor.Transaction.DomainEvents/TransactionSourceAddedToTransactionEvent.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace TransactionProcessor.Transaction.DomainEvents; - -using System; -using Shared.DomainDrivenDesign.EventSourcing; - -public record TransactionSourceAddedToTransactionEvent : DomainEvent -{ - #region Constructors - - public TransactionSourceAddedToTransactionEvent(Guid aggregateId, - Guid estateId, - Guid merchantId, - Int32 transactionSource) : base(aggregateId, Guid.NewGuid()) - { - this.TransactionId = aggregateId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.TransactionSource = transactionSource; - } - - #endregion - - #region Properties - - public Guid EstateId { get; init; } - - public Guid MerchantId { get; init; } - - public Int32 TransactionSource { get; init; } - - public Guid TransactionId { get; init; } - - #endregion -} \ No newline at end of file diff --git a/TransactionProcessor.TransactionAggregate.Tests/DomainEventTests.cs b/TransactionProcessor.TransactionAggregate.Tests/DomainEventTests.cs deleted file mode 100644 index 8d7dcec4..00000000 --- a/TransactionProcessor.TransactionAggregate.Tests/DomainEventTests.cs +++ /dev/null @@ -1,359 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TransactionProcessor.TransactionAggregate.Tests -{ - using EstateManagement.DataTransferObjects; - using Models; - using Shouldly; - using Testing; - using Transaction.DomainEvents; - using Xunit; - using CalculationType = Models.CalculationType; - - public class DomainEventTests - { - [Theory] - [InlineData(TransactionType.Logon)] - [InlineData(TransactionType.Sale)] - public void TransactionHasStartedEvent_CanBeCreated_IsCreated(TransactionType transactionType) - { - TransactionHasStartedEvent transactionHasStartedEvent = new TransactionHasStartedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.TransactionDateTime, - TestData.TransactionNumber, - transactionType.ToString(), - TestData.TransactionReference, - TestData.DeviceIdentifier, - TestData.TransactionAmount); - transactionHasStartedEvent.ShouldNotBeNull(); - transactionHasStartedEvent.AggregateId.ShouldBe(TestData.TransactionId); - transactionHasStartedEvent.TransactionAmount.ShouldBe(TestData.TransactionAmount); - transactionHasStartedEvent.EventId.ShouldNotBe(Guid.Empty); - transactionHasStartedEvent.TransactionId.ShouldBe(TestData.TransactionId); - transactionHasStartedEvent.EstateId.ShouldBe(TestData.EstateId); - transactionHasStartedEvent.DeviceIdentifier.ShouldBe(TestData.DeviceIdentifier); - transactionHasStartedEvent.MerchantId.ShouldBe(TestData.MerchantId); - transactionHasStartedEvent.TransactionDateTime.ShouldBe(TestData.TransactionDateTime); - transactionHasStartedEvent.TransactionNumber.ShouldBe(TestData.TransactionNumber); - transactionHasStartedEvent.TransactionType.ShouldBe(transactionType.ToString()); - transactionHasStartedEvent.TransactionReference.ShouldBe(TestData.TransactionReference); - } - - [Fact] - public void TransactionHasBeenLocallyAuthorisedEvent_CanBeCreated_IsCreated() - { - TransactionHasBeenLocallyAuthorisedEvent transactionHasBeenLocallyAuthorisedEvent = - new TransactionHasBeenLocallyAuthorisedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.AuthorisationCode, - TestData.ResponseCode, - TestData.ResponseMessage); - - transactionHasBeenLocallyAuthorisedEvent.ShouldNotBeNull(); - transactionHasBeenLocallyAuthorisedEvent.AggregateId.ShouldBe(TestData.TransactionId); - transactionHasBeenLocallyAuthorisedEvent.EventId.ShouldNotBe(Guid.Empty); - transactionHasBeenLocallyAuthorisedEvent.TransactionId.ShouldBe(TestData.TransactionId); - transactionHasBeenLocallyAuthorisedEvent.EstateId.ShouldBe(TestData.EstateId); - transactionHasBeenLocallyAuthorisedEvent.MerchantId.ShouldBe(TestData.MerchantId); - transactionHasBeenLocallyAuthorisedEvent.AuthorisationCode.ShouldBe(TestData.AuthorisationCode); - transactionHasBeenLocallyAuthorisedEvent.ResponseCode.ShouldBe(TestData.ResponseCode); - transactionHasBeenLocallyAuthorisedEvent.ResponseMessage.ShouldBe(TestData.ResponseMessage); - } - - [Fact] - public void TransactionHasBeenCompletedEvent_CanBeCreated_IsCreated() - { - TransactionHasBeenCompletedEvent transactionHasBeenCompletedEvent = new TransactionHasBeenCompletedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.ResponseCode, - TestData.ResponseMessage, - TestData.IsAuthorised, - TestData.TransactionDateTime, - TestData.TransactionAmount); - - transactionHasBeenCompletedEvent.ShouldNotBeNull(); - transactionHasBeenCompletedEvent.AggregateId.ShouldBe(TestData.TransactionId); - transactionHasBeenCompletedEvent.EventId.ShouldNotBe(Guid.Empty); - transactionHasBeenCompletedEvent.TransactionId.ShouldBe(TestData.TransactionId); - transactionHasBeenCompletedEvent.EstateId.ShouldBe(TestData.EstateId); - transactionHasBeenCompletedEvent.MerchantId.ShouldBe(TestData.MerchantId); - transactionHasBeenCompletedEvent.ResponseCode.ShouldBe(TestData.ResponseCode); - transactionHasBeenCompletedEvent.ResponseMessage.ShouldBe(TestData.ResponseMessage); - transactionHasBeenCompletedEvent.IsAuthorised.ShouldBe(TestData.IsAuthorised); - transactionHasBeenCompletedEvent.CompletedDateTime.ShouldBe(TestData.TransactionDateTime); - transactionHasBeenCompletedEvent.TransactionAmount.ShouldBe(TestData.TransactionAmount); - } - - [Fact] - public void TransactionHasBeenLocallyDeclinedEvent_CanBeCreated_IsCreated() - { - TransactionHasBeenLocallyDeclinedEvent transactionHasBeenLocallyDeclinedEvent = new TransactionHasBeenLocallyDeclinedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.DeclinedResponseCode, - TestData - .DeclinedResponseMessage); - - transactionHasBeenLocallyDeclinedEvent.ShouldNotBeNull(); - transactionHasBeenLocallyDeclinedEvent.AggregateId.ShouldBe(TestData.TransactionId); - transactionHasBeenLocallyDeclinedEvent.EventId.ShouldNotBe(Guid.Empty); - transactionHasBeenLocallyDeclinedEvent.TransactionId.ShouldBe(TestData.TransactionId); - transactionHasBeenLocallyDeclinedEvent.EstateId.ShouldBe(TestData.EstateId); - transactionHasBeenLocallyDeclinedEvent.MerchantId.ShouldBe(TestData.MerchantId); - transactionHasBeenLocallyDeclinedEvent.ResponseCode.ShouldBe(TestData.DeclinedResponseCode); - transactionHasBeenLocallyDeclinedEvent.ResponseMessage.ShouldBe(TestData.DeclinedResponseMessage); - } - - [Fact] - public void TransactionAuthorisedByOperatorEvent_CanBeCreated_IsCreated() - { - TransactionAuthorisedByOperatorEvent transactionAuthorisedByOperatorEvent = new TransactionAuthorisedByOperatorEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.OperatorIdentifier1, - TestData.OperatorAuthorisationCode, - TestData.OperatorResponseCode, - TestData.OperatorResponseMessage, - TestData.OperatorTransactionId, - TestData.ResponseCode, - TestData.ResponseMessage); - - transactionAuthorisedByOperatorEvent.ShouldNotBeNull(); - transactionAuthorisedByOperatorEvent.AggregateId.ShouldBe(TestData.TransactionId); - transactionAuthorisedByOperatorEvent.EventId.ShouldNotBe(Guid.Empty); - transactionAuthorisedByOperatorEvent.TransactionId.ShouldBe(TestData.TransactionId); - transactionAuthorisedByOperatorEvent.EstateId.ShouldBe(TestData.EstateId); - transactionAuthorisedByOperatorEvent.MerchantId.ShouldBe(TestData.MerchantId); - transactionAuthorisedByOperatorEvent.AuthorisationCode.ShouldBe(TestData.OperatorAuthorisationCode); - transactionAuthorisedByOperatorEvent.OperatorResponseCode.ShouldBe(TestData.OperatorResponseCode); - transactionAuthorisedByOperatorEvent.OperatorResponseMessage.ShouldBe(TestData.OperatorResponseMessage); - transactionAuthorisedByOperatorEvent.OperatorTransactionId.ShouldBe(TestData.OperatorTransactionId); - transactionAuthorisedByOperatorEvent.ResponseCode.ShouldBe(TestData.ResponseCode); - transactionAuthorisedByOperatorEvent.ResponseMessage.ShouldBe(TestData.ResponseMessage); - transactionAuthorisedByOperatorEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); - } - - [Fact] - public void TransactionDeclinedByOperatorEvent_CanBeCreated_IsCreated() - { - TransactionDeclinedByOperatorEvent transactionDeclinedByOperatorEvent = new TransactionDeclinedByOperatorEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.OperatorIdentifier1, - TestData.DeclinedOperatorResponseCode, - TestData.DeclinedOperatorResponseMessage, - TestData.DeclinedResponseCode, - TestData.DeclinedResponseMessage); - - transactionDeclinedByOperatorEvent.ShouldNotBeNull(); - transactionDeclinedByOperatorEvent.AggregateId.ShouldBe(TestData.TransactionId); - transactionDeclinedByOperatorEvent.EventId.ShouldNotBe(Guid.Empty); - transactionDeclinedByOperatorEvent.TransactionId.ShouldBe(TestData.TransactionId); - transactionDeclinedByOperatorEvent.EstateId.ShouldBe(TestData.EstateId); - transactionDeclinedByOperatorEvent.MerchantId.ShouldBe(TestData.MerchantId); - transactionDeclinedByOperatorEvent.OperatorResponseCode.ShouldBe(TestData.DeclinedOperatorResponseCode); - transactionDeclinedByOperatorEvent.OperatorResponseMessage.ShouldBe(TestData.DeclinedOperatorResponseMessage); - transactionDeclinedByOperatorEvent.ResponseCode.ShouldBe(TestData.DeclinedResponseCode); - transactionDeclinedByOperatorEvent.ResponseMessage.ShouldBe(TestData.DeclinedResponseMessage); - transactionDeclinedByOperatorEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); - } - - [Fact] - public void AdditionalResponseDataRecordedEvent_CanBeCreated_IsCreated() - { - AdditionalResponseDataRecordedEvent additionalResponseDataRecordedEvent = new AdditionalResponseDataRecordedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.OperatorIdentifier1, - TestData.AdditionalTransactionMetaDataForMobileTopup()); - - additionalResponseDataRecordedEvent.ShouldNotBeNull(); - additionalResponseDataRecordedEvent.AggregateId.ShouldBe(TestData.TransactionId); - additionalResponseDataRecordedEvent.EventId.ShouldNotBe(Guid.Empty); - additionalResponseDataRecordedEvent.TransactionId.ShouldBe(TestData.TransactionId); - additionalResponseDataRecordedEvent.EstateId.ShouldBe(TestData.EstateId); - additionalResponseDataRecordedEvent.MerchantId.ShouldBe(TestData.MerchantId); - additionalResponseDataRecordedEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); - additionalResponseDataRecordedEvent.AdditionalTransactionResponseMetadata.ShouldNotBeNull(); - - foreach (KeyValuePair keyValuePair in TestData.AdditionalTransactionMetaDataForMobileTopup()) - { - additionalResponseDataRecordedEvent.AdditionalTransactionResponseMetadata.ShouldContainKeyAndValue(keyValuePair.Key, keyValuePair.Value); - } - } - - [Fact] - public void AdditionalRequestDataRecordedEvent_CanBeCreated_IsCreated() - { - AdditionalRequestDataRecordedEvent additionalRequestDataRecordedEvent = new AdditionalRequestDataRecordedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.OperatorIdentifier1, - TestData.AdditionalTransactionMetaDataForMobileTopup()); - - additionalRequestDataRecordedEvent.ShouldNotBeNull(); - additionalRequestDataRecordedEvent.AggregateId.ShouldBe(TestData.TransactionId); - additionalRequestDataRecordedEvent.EventId.ShouldNotBe(Guid.Empty); - additionalRequestDataRecordedEvent.TransactionId.ShouldBe(TestData.TransactionId); - additionalRequestDataRecordedEvent.EstateId.ShouldBe(TestData.EstateId); - additionalRequestDataRecordedEvent.MerchantId.ShouldBe(TestData.MerchantId); - additionalRequestDataRecordedEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier1); - additionalRequestDataRecordedEvent.AdditionalTransactionRequestMetadata.ShouldNotBeNull(); - - foreach (KeyValuePair keyValuePair in TestData.AdditionalTransactionMetaDataForMobileTopup()) - { - additionalRequestDataRecordedEvent.AdditionalTransactionRequestMetadata.ShouldContainKeyAndValue(keyValuePair.Key, keyValuePair.Value); - } - } - - [Fact] - public void CustomerEmailReceiptRequestedEvent_CanBeCreated_IsCreated() - { - CustomerEmailReceiptRequestedEvent customerEmailReceiptRequestedEvent = new CustomerEmailReceiptRequestedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.CustomerEmailAddress); - - customerEmailReceiptRequestedEvent.ShouldNotBeNull(); - customerEmailReceiptRequestedEvent.AggregateId.ShouldBe(TestData.TransactionId); - customerEmailReceiptRequestedEvent.EventId.ShouldNotBe(Guid.Empty); - customerEmailReceiptRequestedEvent.TransactionId.ShouldBe(TestData.TransactionId); - customerEmailReceiptRequestedEvent.EstateId.ShouldBe(TestData.EstateId); - customerEmailReceiptRequestedEvent.MerchantId.ShouldBe(TestData.MerchantId); - customerEmailReceiptRequestedEvent.CustomerEmailAddress.ShouldBe(TestData.CustomerEmailAddress); - } - - [Fact] - public void CustomerEmailReceiptResendRequestedEvent_CanBeCreated_IsCreated() - { - CustomerEmailReceiptResendRequestedEvent customerEmailReceiptResendRequestedEvent = new CustomerEmailReceiptResendRequestedEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId); - - customerEmailReceiptResendRequestedEvent.ShouldNotBeNull(); - customerEmailReceiptResendRequestedEvent.AggregateId.ShouldBe(TestData.TransactionId); - customerEmailReceiptResendRequestedEvent.EventId.ShouldNotBe(Guid.Empty); - customerEmailReceiptResendRequestedEvent.TransactionId.ShouldBe(TestData.TransactionId); - customerEmailReceiptResendRequestedEvent.EstateId.ShouldBe(TestData.EstateId); - customerEmailReceiptResendRequestedEvent.MerchantId.ShouldBe(TestData.MerchantId); - } - - [Fact] - public void ProductDetailsAddedToTransactionEvent_CanBeCreated_IsCreated() - { - ProductDetailsAddedToTransactionEvent productDetailsAddedToTransactionEvent = new ProductDetailsAddedToTransactionEvent(TestData.TransactionId, TestData.EstateId,TestData.MerchantId, TestData.ContractId, TestData.ProductId); - - productDetailsAddedToTransactionEvent.ShouldNotBeNull(); - productDetailsAddedToTransactionEvent.AggregateId.ShouldBe(TestData.TransactionId); - productDetailsAddedToTransactionEvent.EventId.ShouldNotBe(Guid.Empty); - productDetailsAddedToTransactionEvent.TransactionId.ShouldBe(TestData.TransactionId); - productDetailsAddedToTransactionEvent.EstateId.ShouldBe(TestData.EstateId); - productDetailsAddedToTransactionEvent.MerchantId.ShouldBe(TestData.MerchantId); - productDetailsAddedToTransactionEvent.ProductId.ShouldBe(TestData.ProductId); - productDetailsAddedToTransactionEvent.ContractId.ShouldBe(TestData.ContractId); - } - - [Fact] - public void SettledMerchantFeeAddedToTransactionEvent_CanBeCreated_IsCreated() - { - SettledMerchantFeeAddedToTransactionEvent settledMerchantFeeAddedToTransactionEvent = new SettledMerchantFeeAddedToTransactionEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.CalculatedFeeValue, - (Int32)CalculationType.Fixed, - TestData.TransactionFeeId, - TestData.TransactionFeeValue, - TestData.TransactionFeeCalculateDateTime, - TestData.TransactionFeeSettledDateTime, - TestData.SettlementAggregateId); - - settledMerchantFeeAddedToTransactionEvent.ShouldNotBeNull(); - settledMerchantFeeAddedToTransactionEvent.AggregateId.ShouldBe(TestData.TransactionId); - settledMerchantFeeAddedToTransactionEvent.EventId.ShouldNotBe(Guid.Empty); - settledMerchantFeeAddedToTransactionEvent.TransactionId.ShouldBe(TestData.TransactionId); - settledMerchantFeeAddedToTransactionEvent.EstateId.ShouldBe(TestData.EstateId); - settledMerchantFeeAddedToTransactionEvent.MerchantId.ShouldBe(TestData.MerchantId); - settledMerchantFeeAddedToTransactionEvent.CalculatedValue.ShouldBe(TestData.CalculatedFeeValue); - settledMerchantFeeAddedToTransactionEvent.FeeCalculationType.ShouldBe((Int32)CalculationType.Fixed); - settledMerchantFeeAddedToTransactionEvent.FeeId.ShouldBe(TestData.TransactionFeeId); - settledMerchantFeeAddedToTransactionEvent.FeeValue.ShouldBe(TestData.TransactionFeeValue); - settledMerchantFeeAddedToTransactionEvent.FeeCalculatedDateTime.ShouldBe(TestData.TransactionFeeCalculateDateTime); - settledMerchantFeeAddedToTransactionEvent.SettledDateTime.ShouldBe(TestData.TransactionFeeSettledDateTime); - - } - - [Fact] - public void ServiceProviderFeeAddedToTransactionEvent_CanBeCreated_IsCreated() - { - ServiceProviderFeeAddedToTransactionEvent serviceProviderFeeAddedToTransactionEvent = new ServiceProviderFeeAddedToTransactionEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.CalculatedFeeValue, - (Int32)CalculationType.Fixed, - TestData.TransactionFeeId, - TestData.TransactionFeeValue, - TestData.TransactionFeeCalculateDateTime); - - serviceProviderFeeAddedToTransactionEvent.ShouldNotBeNull(); - serviceProviderFeeAddedToTransactionEvent.AggregateId.ShouldBe(TestData.TransactionId); - serviceProviderFeeAddedToTransactionEvent.EventId.ShouldNotBe(Guid.Empty); - serviceProviderFeeAddedToTransactionEvent.TransactionId.ShouldBe(TestData.TransactionId); - serviceProviderFeeAddedToTransactionEvent.EstateId.ShouldBe(TestData.EstateId); - serviceProviderFeeAddedToTransactionEvent.MerchantId.ShouldBe(TestData.MerchantId); - serviceProviderFeeAddedToTransactionEvent.CalculatedValue.ShouldBe(TestData.CalculatedFeeValue); - serviceProviderFeeAddedToTransactionEvent.FeeCalculationType.ShouldBe((Int32)CalculationType.Fixed); - serviceProviderFeeAddedToTransactionEvent.FeeId.ShouldBe(TestData.TransactionFeeId); - serviceProviderFeeAddedToTransactionEvent.FeeValue.ShouldBe(TestData.TransactionFeeValue); - serviceProviderFeeAddedToTransactionEvent.FeeCalculatedDateTime.ShouldBe(TestData.TransactionFeeCalculateDateTime); - } - - [Fact] - public void TransactionSourceAddedToTransactionEvent_CanBeCreated_IsCreated() - { - TransactionSourceAddedToTransactionEvent transactionSourceAddedToTransactionEvent = new TransactionSourceAddedToTransactionEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.TransactionSource); - - transactionSourceAddedToTransactionEvent.ShouldNotBeNull(); - transactionSourceAddedToTransactionEvent.AggregateId.ShouldBe(TestData.TransactionId); - transactionSourceAddedToTransactionEvent.EventId.ShouldNotBe(Guid.Empty); - transactionSourceAddedToTransactionEvent.TransactionId.ShouldBe(TestData.TransactionId); - transactionSourceAddedToTransactionEvent.EstateId.ShouldBe(TestData.EstateId); - transactionSourceAddedToTransactionEvent.MerchantId.ShouldBe(TestData.MerchantId); - transactionSourceAddedToTransactionEvent.TransactionSource.ShouldBe(TestData.TransactionSource); - } - - [Fact] - public void MerchantFeePendingSettlementAddedToTransactionEvent_CanBeCreated_IsCreated() - { - MerchantFeePendingSettlementAddedToTransactionEvent merchantFeePendingSettlementAddedToTransactionEvent = new MerchantFeePendingSettlementAddedToTransactionEvent(TestData.TransactionId, - TestData.EstateId, - TestData.MerchantId, - TestData.CalculatedFeeValue, - (Int32)CalculationType.Fixed, - TestData.TransactionFeeId, - TestData.TransactionFeeValue, - TestData.TransactionFeeCalculateDateTime, - TestData.TransactionFeeSettlementDueDate); - - merchantFeePendingSettlementAddedToTransactionEvent.ShouldNotBeNull(); - merchantFeePendingSettlementAddedToTransactionEvent.AggregateId.ShouldBe(TestData.TransactionId); - merchantFeePendingSettlementAddedToTransactionEvent.EventId.ShouldNotBe(Guid.Empty); - merchantFeePendingSettlementAddedToTransactionEvent.TransactionId.ShouldBe(TestData.TransactionId); - merchantFeePendingSettlementAddedToTransactionEvent.EstateId.ShouldBe(TestData.EstateId); - merchantFeePendingSettlementAddedToTransactionEvent.MerchantId.ShouldBe(TestData.MerchantId); - merchantFeePendingSettlementAddedToTransactionEvent.CalculatedValue.ShouldBe(TestData.CalculatedFeeValue); - merchantFeePendingSettlementAddedToTransactionEvent.FeeCalculationType.ShouldBe((Int32)CalculationType.Fixed); - merchantFeePendingSettlementAddedToTransactionEvent.FeeId.ShouldBe(TestData.TransactionFeeId); - merchantFeePendingSettlementAddedToTransactionEvent.FeeValue.ShouldBe(TestData.TransactionFeeValue); - merchantFeePendingSettlementAddedToTransactionEvent.FeeCalculatedDateTime.ShouldBe(TestData.TransactionFeeCalculateDateTime); - merchantFeePendingSettlementAddedToTransactionEvent.SettlementDueDate.ShouldBe(TestData.TransactionFeeSettlementDueDate); - } - } -} diff --git a/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs b/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs index 5f3295c9..a31b17ea 100644 --- a/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs +++ b/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs @@ -758,7 +758,6 @@ public void TransactionAggregate_CompleteTransaction_TransactionIsCompleted(Tran transactionAggregate.CompleteTransaction(); - transactionAggregate.IsStarted.ShouldBeFalse(); transactionAggregate.IsCompleted.ShouldBeTrue(); } @@ -1646,18 +1645,19 @@ public void TransactionAggregate_AddFeePendingSettlement_LogonTransaction_ErrorT Should.Throw(() => { transactionAggregate.AddFeePendingSettlement(this.GetCalculatedFeeToAdd(feeType), DateTime.Now); }); } - public static TheoryData TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecorded_Data => + public static TheoryData TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecorded_Data => new() { - { 0,0,null,null }, - { 0,1,null,null }, - { 1,0,null,null }, - { 0.9m,90m,0.9m,90m}, + { 0,0,null,null, false}, + { 0,1,null,null, false }, + { 1,0,null,null, false }, + { 0.9m,90m,0.9m,90m, true}, }; [Theory] [MemberData(nameof(TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecorded_Data))] - public void TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecorded(Decimal unitCost, Decimal totalCost, Decimal? expectedUnitCost, Decimal? expectedTotalCost){ + public void TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecorded(Decimal unitCost, Decimal totalCost, Decimal? expectedUnitCost, Decimal? expectedTotalCost, Boolean expectedCostsCalculated) + { TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, @@ -1669,9 +1669,10 @@ public void TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecord TestData.TransactionAmount); transactionAggregate.RecordCostPrice(unitCost, totalCost); - + transactionAggregate.UnitCost.ShouldBe(expectedUnitCost); transactionAggregate.TotalCost.ShouldBe(expectedTotalCost); + transactionAggregate.HasCostsCalculated.ShouldBe(expectedCostsCalculated); } [Fact] diff --git a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs b/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs index 58b7f774..6a737ff3 100644 --- a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs +++ b/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs @@ -569,7 +569,7 @@ public static void PlayEvent(this TransactionAggregate aggregate, TransactionHas public static void PlayEvent(this TransactionAggregate aggregate, TransactionHasBeenCompletedEvent domainEvent) { - aggregate.IsStarted = false; // Transaction has reached its final state + //aggregate.IsStarted = false; // Transaction has reached its final state aggregate.IsCompleted = true; } @@ -608,6 +608,7 @@ public static void PlayEvent(this TransactionAggregate aggregate, TransactionSou public static void PlayEvent(this TransactionAggregate aggregate, TransactionCostInformationRecordedEvent domainEvent){ aggregate.UnitCost = domainEvent.UnitCostValue; aggregate.TotalCost = domainEvent.TotalCostValue; + aggregate.HasCostsCalculated= true; } public static void PlayEvent(this TransactionAggregate aggregate, SettledMerchantFeeAddedToTransactionEvent domainEvent) @@ -733,10 +734,11 @@ private TransactionAggregate(Guid aggregateId) { public Int32 ReceiptResendCount { get; internal set; } + public Boolean HasCostsCalculated{ get; internal set; } + #endregion #region Methods - public static TransactionAggregate Create(Guid aggregateId) { return new TransactionAggregate(aggregateId); @@ -751,10 +753,6 @@ protected override Object GetMetadata() { }; } - - - - #endregion } } \ No newline at end of file diff --git a/TransactionProcessor.Voucher.DomainEvents/BarcodeAddedEvent.cs b/TransactionProcessor.Voucher.DomainEvents/BarcodeAddedEvent.cs deleted file mode 100644 index 49b459d7..00000000 --- a/TransactionProcessor.Voucher.DomainEvents/BarcodeAddedEvent.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace TransactionProcessor.Voucher.DomainEvents; - -using Shared.DomainDrivenDesign.EventSourcing; - -public record BarcodeAddedEvent : DomainEvent -{ - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The barcode. - public BarcodeAddedEvent(Guid aggregateId, - Guid estateId, - String barcode) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.VoucherId = aggregateId; - this.Barcode = barcode; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the barcode. - /// - /// - /// The barcode. - /// - public String Barcode { get; init; } - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - /// - /// Gets or sets the voucher identifier. - /// - /// - /// The voucher identifier. - /// - public Guid VoucherId { get; init; } - - #endregion -} \ No newline at end of file diff --git a/TransactionProcessor.Voucher.DomainEvents/VoucherAggregateDomainEvents.cs b/TransactionProcessor.Voucher.DomainEvents/VoucherAggregateDomainEvents.cs new file mode 100644 index 00000000..c0af13e8 --- /dev/null +++ b/TransactionProcessor.Voucher.DomainEvents/VoucherAggregateDomainEvents.cs @@ -0,0 +1,32 @@ +namespace TransactionProcessor.Voucher.DomainEvents{ + using System.Diagnostics.CodeAnalysis; + using Shared.DomainDrivenDesign.EventSourcing; + + [ExcludeFromCodeCoverage] + public record BarcodeAddedEvent(Guid VoucherId, + Guid EstateId, + String Barcode) : DomainEvent(VoucherId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record VoucherFullyRedeemedEvent(Guid VoucherId, + Guid EstateId, + DateTime RedeemedDateTime) : DomainEvent(VoucherId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record VoucherGeneratedEvent(Guid VoucherId, + Guid EstateId, + Guid TransactionId, + DateTime GeneratedDateTime, + String OperatorIdentifier, + Decimal Value, + String VoucherCode, + DateTime ExpiryDateTime, + String Message) : DomainEvent(VoucherId, Guid.NewGuid()); + + [ExcludeFromCodeCoverage] + public record VoucherIssuedEvent(Guid VoucherId, + Guid EstateId, + DateTime IssuedDateTime, + String RecipientEmail, + String RecipientMobile) : DomainEvent(VoucherId, Guid.NewGuid()); +} \ No newline at end of file diff --git a/TransactionProcessor.Voucher.DomainEvents/VoucherFullyRedeemedEvent.cs b/TransactionProcessor.Voucher.DomainEvents/VoucherFullyRedeemedEvent.cs deleted file mode 100644 index ca1d1a3b..00000000 --- a/TransactionProcessor.Voucher.DomainEvents/VoucherFullyRedeemedEvent.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace TransactionProcessor.Voucher.DomainEvents; - -using Shared.DomainDrivenDesign.EventSourcing; - -public record VoucherFullyRedeemedEvent : DomainEvent -{ - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The redeemed date time. - public VoucherFullyRedeemedEvent(Guid aggregateId, - Guid estateId, - DateTime redeemedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.RedeemedDateTime = redeemedDateTime; - this.VoucherId = aggregateId; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets or sets the redeemed date time. - /// - /// - /// The redeemed date time. - /// - public DateTime RedeemedDateTime { get; init; } - - /// - /// Gets or sets the voucher identifier. - /// - /// - /// The voucher identifier. - /// - public Guid VoucherId { get; init; } - - #endregion -} \ No newline at end of file diff --git a/TransactionProcessor.Voucher.DomainEvents/VoucherGeneratedEvent.cs b/TransactionProcessor.Voucher.DomainEvents/VoucherGeneratedEvent.cs deleted file mode 100644 index 6970d2e4..00000000 --- a/TransactionProcessor.Voucher.DomainEvents/VoucherGeneratedEvent.cs +++ /dev/null @@ -1,106 +0,0 @@ -namespace TransactionProcessor.Voucher.DomainEvents; - -using Shared.DomainDrivenDesign.EventSourcing; - -public record VoucherGeneratedEvent : DomainEvent -{ - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets or sets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - public Guid TransactionId { get; init; } - /// - /// Gets or sets the voucher identifier. - /// - /// - /// The voucher identifier. - /// - public Guid VoucherId { get; init; } - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - public String OperatorIdentifier { get; init; } - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - public Decimal Value { get; init; } - - /// - /// Gets or sets the voucher code. - /// - /// - /// The voucher code. - /// - public String VoucherCode { get; init; } - - /// - /// Gets or sets the expiry date time. - /// - /// - /// The expiry date time. - /// - public DateTime ExpiryDateTime { get; init; } - /// - /// Gets or sets the generated date time. - /// - /// - /// The generated date time. - /// - public DateTime GeneratedDateTime { get; init; } - /// - /// Gets or sets the message. - /// - /// - /// The message. - /// - public String Message { get; init; } - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The transaction identifier. - /// The generated date time. - /// The operator identifier. - /// The value. - /// The voucher code. - /// The expiry date time. - /// The message. - public VoucherGeneratedEvent(Guid aggregateId, - Guid estateId, - Guid transactionId, - DateTime generatedDateTime, - String operatorIdentifier, - Decimal value, - String voucherCode, - DateTime expiryDateTime, - String message) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.TransactionId = transactionId; - this.GeneratedDateTime = generatedDateTime; - this.OperatorIdentifier = operatorIdentifier; - this.Value = value; - this.VoucherCode = voucherCode; - this.ExpiryDateTime = expiryDateTime; - this.Message = message; - this.VoucherId = aggregateId; - } -} \ No newline at end of file diff --git a/TransactionProcessor.Voucher.DomainEvents/VoucherIssuedEvent.cs b/TransactionProcessor.Voucher.DomainEvents/VoucherIssuedEvent.cs deleted file mode 100644 index b887b0d6..00000000 --- a/TransactionProcessor.Voucher.DomainEvents/VoucherIssuedEvent.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace TransactionProcessor.Voucher.DomainEvents -{ - using Newtonsoft.Json; - using Shared.DomainDrivenDesign.EventSourcing; - - public record VoucherIssuedEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The estate identifier. - /// The issued date time. - /// The recipient email. - /// The recipient mobile. - public VoucherIssuedEvent(Guid aggregateId, - Guid estateId, - DateTime issuedDateTime, - String recipientEmail, - String recipientMobile) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.VoucherId = aggregateId; - this.IssuedDateTime = issuedDateTime; - this.RecipientEmail = recipientEmail; - this.RecipientMobile = recipientMobile; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets or sets the issued date time. - /// - /// - /// The issued date time. - /// - public DateTime IssuedDateTime { get; init; } - - /// - /// Gets or sets the recipient email. - /// - /// - /// The recipient email. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public String RecipientEmail { get; init; } - - /// - /// Gets or sets the recipient mobile. - /// - /// - /// The recipient mobile. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public String RecipientMobile { get; init; } - - /// - /// Gets or sets the voucher identifier. - /// - /// - /// The voucher identifier. - /// - public Guid VoucherId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.VoucherAggregate.Tests/DomainEventTests.cs b/TransactionProcessor.VoucherAggregate.Tests/DomainEventTests.cs deleted file mode 100644 index 4c2b3d67..00000000 --- a/TransactionProcessor.VoucherAggregate.Tests/DomainEventTests.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace TransactionProcessor.VoucherAggregate.Tests -{ - using Shouldly; - using Testing; - using Voucher.DomainEvents; - using Xunit; - - public class DomainEventTests - { - [Fact] - public void VoucherGeneratedEvent_CanBeCreated_IsCreated() - { - VoucherGeneratedEvent voucherGeneratedEvent = new VoucherGeneratedEvent(TestData.VoucherId, TestData.EstateId, - TestData.TransactionId, TestData.IssuedDateTime, - TestData.OperatorIdentifier, - TestData.Value, TestData.VoucherCode, TestData.ExpiryDate, - TestData.Message); - - voucherGeneratedEvent.ShouldNotBeNull(); - voucherGeneratedEvent.AggregateId.ShouldBe(TestData.VoucherId); - voucherGeneratedEvent.EventId.ShouldNotBe(Guid.Empty); - voucherGeneratedEvent.VoucherId.ShouldBe(TestData.VoucherId); - voucherGeneratedEvent.EstateId.ShouldBe(TestData.EstateId); - voucherGeneratedEvent.OperatorIdentifier.ShouldBe(TestData.OperatorIdentifier); - voucherGeneratedEvent.Value.ShouldBe(TestData.Value); - voucherGeneratedEvent.VoucherCode.ShouldBe(TestData.VoucherCode); - voucherGeneratedEvent.ExpiryDateTime.ShouldBe(TestData.ExpiryDate); - voucherGeneratedEvent.Message.ShouldBe(TestData.Message); - voucherGeneratedEvent.GeneratedDateTime.ShouldBe(TestData.IssuedDateTime); - } - - [Fact] - public void VoucherIssuedEvent_CanBeCreated_IsCreated() - { - VoucherIssuedEvent voucherIssuedEvent = new VoucherIssuedEvent(TestData.VoucherId, TestData.EstateId, TestData.IssuedDateTime, TestData.RecipientEmail, TestData.RecipientMobile); - - voucherIssuedEvent.ShouldNotBeNull(); - voucherIssuedEvent.AggregateId.ShouldBe(TestData.VoucherId); - voucherIssuedEvent.EventId.ShouldNotBe(Guid.Empty); - voucherIssuedEvent.VoucherId.ShouldBe(TestData.VoucherId); - voucherIssuedEvent.EstateId.ShouldBe(TestData.EstateId); - voucherIssuedEvent.RecipientEmail.ShouldBe(TestData.RecipientEmail); - voucherIssuedEvent.RecipientMobile.ShouldBe(TestData.RecipientMobile); - voucherIssuedEvent.IssuedDateTime.ShouldBe(TestData.IssuedDateTime); - } - - [Fact] - public void BarcodeAddedEvent_CanBeCreated_IsCreated() - { - BarcodeAddedEvent barcodeAddedEvent = new BarcodeAddedEvent(TestData.VoucherId, TestData.EstateId, TestData.Barcode); - - barcodeAddedEvent.ShouldNotBeNull(); - barcodeAddedEvent.AggregateId.ShouldBe(TestData.VoucherId); - barcodeAddedEvent.EventId.ShouldNotBe(Guid.Empty); - barcodeAddedEvent.VoucherId.ShouldBe(TestData.VoucherId); - barcodeAddedEvent.EstateId.ShouldBe(TestData.EstateId); - barcodeAddedEvent.Barcode.ShouldBe(TestData.Barcode); - } - - [Fact] - public void VoucherFullyRedeemedEvent_CanBeCreated_IsCreated() - { - VoucherFullyRedeemedEvent voucherFullyRedeemedEvent = new VoucherFullyRedeemedEvent(TestData.VoucherId, TestData.EstateId, TestData.RedeemedDateTime); - - voucherFullyRedeemedEvent.ShouldNotBeNull(); - voucherFullyRedeemedEvent.AggregateId.ShouldBe(TestData.VoucherId); - voucherFullyRedeemedEvent.EventId.ShouldNotBe(Guid.Empty); - voucherFullyRedeemedEvent.VoucherId.ShouldBe(TestData.VoucherId); - voucherFullyRedeemedEvent.EstateId.ShouldBe(TestData.EstateId); - voucherFullyRedeemedEvent.RedeemedDateTime.ShouldBe(TestData.RedeemedDateTime); - } - } -} \ No newline at end of file diff --git a/TransactionProcessor/appsettings.json b/TransactionProcessor/appsettings.json index 1933226b..60d31633 100644 --- a/TransactionProcessor/appsettings.json +++ b/TransactionProcessor/appsettings.json @@ -21,6 +21,9 @@ ], "VoucherIssuedEvent": [ "TransactionProcessor.BusinessLogic.EventHandling.VoucherDomainEventHandler, TransactionProcessor.BusinessLogic" + ], + "TransactionCostInformationRecordedEvent": [ + "TransactionProcessor.BusinessLogic.EventHandling.VoucherDomainEventHandler, TransactionProcessor.BusinessLogic" ] }, "EventHandlerConfigurationOrdered": {