From f9131b00f9eb7a0d1e43f9d187742c8132739be1 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Sun, 3 Oct 2021 20:00:58 +0100 Subject: [PATCH 01/14] Take settlement date of txn completion date --- .../TransactionDomainEventHandler.cs | 21 +++++++- .../Settlement/Settlement.feature | 12 ++--- .../Settlement/Settlement.feature.cs | 48 +++++++++---------- .../Shared/SharedSteps.cs | 13 +++-- 4 files changed, 57 insertions(+), 37 deletions(-) diff --git a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs index 19f91de6..390dd03f 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs @@ -238,14 +238,18 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do foreach (CalculatedFee calculatedFee in merchantFees) { // Determine when the fee should be applied - Guid aggregateId = merchant.NextSettlementDueDate.ToGuid(); + Logger.LogInformation($"Completed Date {domainEvent.CompletedDateTime}"); + Logger.LogInformation($"SettlementSchedule {merchant.SettlementSchedule}"); + DateTime settlementDate = CalculateSettlementDate(merchant.SettlementSchedule, domainEvent.CompletedDateTime); + Logger.LogInformation($"Settlement Date {settlementDate}"); + Guid aggregateId = settlementDate.ToGuid(); // We need to add the fees to a pending settlement stream (for today) SettlementAggregate aggregate = await this.SettlementAggregateRepository.GetLatestVersion(aggregateId, cancellationToken); if (aggregate.IsCreated == false) { - aggregate.Create(transactionAggregate.EstateId, merchant.NextSettlementDueDate); + aggregate.Create(transactionAggregate.EstateId, settlementDate); } aggregate.AddFee(transactionAggregate.MerchantId, transactionAggregate.AggregateId, calculatedFee); @@ -255,6 +259,19 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do } } + private DateTime CalculateSettlementDate(SettlementSchedule merchantSettlementSchedule, DateTime completeDateTime) + { + switch(merchantSettlementSchedule) + { + case SettlementSchedule.Weekly: + return completeDateTime.Date.AddDays(7).Date; + case SettlementSchedule.Monthly: + return completeDateTime.Date.AddMonths(1).Date; + default: + throw new Exception("Invalid merchant settlement schedule"); + } + } + /// /// Handles the specific domain event. /// diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature index d268dfcd..91ec227a 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature @@ -97,9 +97,9 @@ Scenario: Get Pending Settlement | Test Estate 1 | Test Merchant 3 | 8 | 0000 | SUCCESS | When I get the pending settlements the following information should be returned - | NextSettlementDate | EstateName | NumberOfFees | - | NextWeek | Test Estate 1 | 1 | - | NextMonth | Test Estate 1 | 1 | + | SettlementDate | EstateName | NumberOfFees | + | NextWeek | Test Estate 1 | 1 | + | NextMonth | Test Estate 1 | 1 | @PRTest Scenario: Process Settlement @@ -142,9 +142,9 @@ Scenario: Process Settlement | Test Estate 1 | Test Merchant 2 | 6 | 0000 | SUCCESS | When I get the pending settlements the following information should be returned - | NextSettlementDate | EstateName | NumberOfFees | - | NextWeek | Test Estate 1 | 1 | + | SettlementDate | EstateName | NumberOfFees | + | Yesterday | Test Estate 1 | 1 | - When I process the settlement for 'NextWeek' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed + When I process the settlement for 'Yesterday' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs index fc3e5cbc..c8e5ea31 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs @@ -247,14 +247,12 @@ void System.IDisposable.Dispose() [Xunit.SkippableFactAttribute(DisplayName="Get Pending Settlement")] [Xunit.TraitAttribute("FeatureTitle", "Settlement")] [Xunit.TraitAttribute("Description", "Get Pending Settlement")] - [Xunit.TraitAttribute("Category", "PRTest")] public virtual void GetPendingSettlement() { - string[] tagsOfScenario = new string[] { - "PRTest"}; + string[] tagsOfScenario = ((string[])(null)); System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get Pending Settlement", null, tagsOfScenario, argumentsOfScenario); -#line 50 +#line 49 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -317,7 +315,7 @@ public virtual void GetPendingSettlement() "testcontact3@merchant2.co.uk", "Test Estate 1", "Monthly"}); -#line 51 +#line 50 testRunner.Given("I create the following merchants", ((string)(null)), table71, "Given "); #line hidden TechTalk.SpecFlow.Table table72 = new TechTalk.SpecFlow.Table(new string[] { @@ -362,7 +360,7 @@ public virtual void GetPendingSettlement() "00000003", "10000003", "Test Estate 1"}); -#line 57 +#line 56 testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table72, "Given "); #line hidden TechTalk.SpecFlow.Table table73 = new TechTalk.SpecFlow.Table(new string[] { @@ -381,7 +379,7 @@ public virtual void GetPendingSettlement() "123456782", "Test Merchant 3", "Test Estate 1"}); -#line 66 +#line 65 testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table73, "Given "); #line hidden TechTalk.SpecFlow.Table table74 = new TechTalk.SpecFlow.Table(new string[] { @@ -408,7 +406,7 @@ public virtual void GetPendingSettlement() "Today", "Test Merchant 3", "Test Estate 1"}); -#line 72 +#line 71 testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table74, "Given "); #line hidden TechTalk.SpecFlow.Table table75 = new TechTalk.SpecFlow.Table(new string[] { @@ -546,7 +544,7 @@ public virtual void GetPendingSettlement() "10 KES", "test@recipient.co.uk", ""}); -#line 78 +#line 77 testRunner.When("I perform the following transactions", ((string)(null)), table75, "When "); #line hidden TechTalk.SpecFlow.Table table76 = new TechTalk.SpecFlow.Table(new string[] { @@ -603,11 +601,11 @@ public virtual void GetPendingSettlement() "8", "0000", "SUCCESS"}); -#line 89 +#line 88 testRunner.Then("transaction response should contain the following information", ((string)(null)), table76, "Then "); #line hidden TechTalk.SpecFlow.Table table77 = new TechTalk.SpecFlow.Table(new string[] { - "NextSettlementDate", + "SettlementDate", "EstateName", "NumberOfFees"}); table77.AddRow(new string[] { @@ -618,7 +616,7 @@ public virtual void GetPendingSettlement() "NextMonth", "Test Estate 1", "1"}); -#line 101 +#line 99 testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table77, "When "); #line hidden } @@ -635,7 +633,7 @@ public virtual void ProcessSettlement() "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Process Settlement", null, tagsOfScenario, argumentsOfScenario); -#line 107 +#line 105 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -688,7 +686,7 @@ public virtual void ProcessSettlement() "testcontact2@merchant2.co.uk", "Test Estate 1", "Weekly"}); -#line 108 +#line 106 testRunner.Given("I create the following merchants", ((string)(null)), table78, "Given "); #line hidden TechTalk.SpecFlow.Table table79 = new TechTalk.SpecFlow.Table(new string[] { @@ -721,7 +719,7 @@ public virtual void ProcessSettlement() "00000002", "10000002", "Test Estate 1"}); -#line 113 +#line 111 testRunner.Given("I have assigned the following operator to the merchants", ((string)(null)), table79, "Given "); #line hidden TechTalk.SpecFlow.Table table80 = new TechTalk.SpecFlow.Table(new string[] { @@ -736,7 +734,7 @@ public virtual void ProcessSettlement() "123456781", "Test Merchant 2", "Test Estate 1"}); -#line 120 +#line 118 testRunner.Given("I have assigned the following devices to the merchants", ((string)(null)), table80, "Given "); #line hidden TechTalk.SpecFlow.Table table81 = new TechTalk.SpecFlow.Table(new string[] { @@ -757,7 +755,7 @@ public virtual void ProcessSettlement() "Today", "Test Merchant 2", "Test Estate 1"}); -#line 125 +#line 123 testRunner.Given("I make the following manual merchant deposits", ((string)(null)), table81, "Given "); #line hidden TechTalk.SpecFlow.Table table82 = new TechTalk.SpecFlow.Table(new string[] { @@ -850,7 +848,7 @@ public virtual void ProcessSettlement() "10 KES", "", "123456789"}); -#line 130 +#line 128 testRunner.When("I perform the following transactions", ((string)(null)), table82, "When "); #line hidden TechTalk.SpecFlow.Table table83 = new TechTalk.SpecFlow.Table(new string[] { @@ -889,23 +887,23 @@ public virtual void ProcessSettlement() "6", "0000", "SUCCESS"}); -#line 138 +#line 136 testRunner.Then("transaction response should contain the following information", ((string)(null)), table83, "Then "); #line hidden TechTalk.SpecFlow.Table table84 = new TechTalk.SpecFlow.Table(new string[] { - "NextSettlementDate", + "SettlementDate", "EstateName", "NumberOfFees"}); table84.AddRow(new string[] { - "NextWeek", + "Yesterday", "Test Estate 1", "1"}); -#line 146 +#line 144 testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table84, "When "); #line hidden -#line 150 - testRunner.When("I process the settlement for \'NextWeek\' on Estate \'Test Estate 1\' then 1 fees are" + - " marked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 148 + testRunner.When("I process the settlement for \'Yesterday\' on Estate \'Test Estate 1\' then 1 fees ar" + + "e marked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden } this.ScenarioCleanup(); diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 22b82b62..ad10dcb0 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -877,15 +877,15 @@ public async Task WhenIGetThePendingSettlementsTheFollowingInformationShouldBeRe { // Get the merchant name EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); - String nextSettlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "NextSettlementDate"); + String settlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "SettlementDate"); Int32 numberOfFees = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfFees"); - DateTime nextSettlementDate = this.GetNextSettlementDate(DateTime.Now, nextSettlementDateString); + DateTime settlementDate = this.GetSettlementDate(DateTime.Now, settlementDateString); await Retry.For(async () => { SettlementResponse settlements = await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementByDate(this.TestingContext.AccessToken, - nextSettlementDate, + settlementDate, estateDetails.EstateId, CancellationToken.None); @@ -918,9 +918,14 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB }); } - private DateTime GetNextSettlementDate(DateTime now, + private DateTime GetSettlementDate(DateTime now, String nextSettlementDate) { + if (nextSettlementDate == "Yesterday") + { + return now.AddDays(-1); + } + if (nextSettlementDate == "NextWeek") { return now.AddDays(7); From 9cf166cd1b07264bab7f7dddcc1931fd2f8f7192 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 4 Oct 2021 13:50:43 +0100 Subject: [PATCH 02/14] :| --- .../Shared/SharedSteps.cs | 13 +++++++------ .../TransactionProcessor.IntegrationTests.csproj | 1 + .../Controllers/SettlementController.cs | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index ad10dcb0..9bb07b14 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -9,6 +9,7 @@ namespace TransactionProcessor.IntegrationTests.Shared using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; + using BusinessLogic.Common; using Common; using DataTransferObjects; using EstateManagement.DataTransferObjects; @@ -880,7 +881,7 @@ public async Task WhenIGetThePendingSettlementsTheFollowingInformationShouldBeRe String settlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "SettlementDate"); Int32 numberOfFees = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfFees"); DateTime settlementDate = this.GetSettlementDate(DateTime.Now, settlementDateString); - + var aggregateid = settlementDate.ToGuid(); await Retry.For(async () => { SettlementResponse settlements = @@ -915,7 +916,7 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB settlement.NumberOfFeesPendingSettlement.ShouldBe(0); settlement.NumberOfFeesSettled.ShouldBe(numberOfFeesSettled); settlement.SettlementCompleted.ShouldBeTrue(); - }); + }, TimeSpan.FromMinutes(2)); } private DateTime GetSettlementDate(DateTime now, @@ -923,20 +924,20 @@ private DateTime GetSettlementDate(DateTime now, { if (nextSettlementDate == "Yesterday") { - return now.AddDays(-1); + return now.Date.AddDays(-1).Date; } if (nextSettlementDate == "NextWeek") { - return now.AddDays(7); + return now.Date.AddHours(-1).AddDays(7).Date; } if (nextSettlementDate == "NextMonth") { - return now.AddMonths(1); + return now.Date.AddHours(-1).AddMonths(1).Date; } - return now; + return now.Date; } } } diff --git a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj index e2aafeb1..1071db15 100644 --- a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj +++ b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj @@ -34,6 +34,7 @@ + diff --git a/TransactionProcessor/Controllers/SettlementController.cs b/TransactionProcessor/Controllers/SettlementController.cs index c44ee5e4..8dda2e69 100644 --- a/TransactionProcessor/Controllers/SettlementController.cs +++ b/TransactionProcessor/Controllers/SettlementController.cs @@ -16,6 +16,7 @@ namespace TransactionProcessor.Controllers using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; + using Shared.Logger; [ExcludeFromCodeCoverage] [Route(SettlementController.ControllerRoute)] @@ -60,6 +61,8 @@ public async Task GetPendingSettlement([FromRoute] DateTime settl // Convert the date passed in to a guid var aggregateId = settlementDate.Date.ToGuid(); + Logger.LogInformation($"Settlement Aggregate Id {aggregateId}"); + var settlementAggregate = await this.SettlmentAggregateRepository.GetLatestVersion(aggregateId, cancellationToken); var settlementResponse = new SettlementResponse From 2139d953c5cb3e6e7aea295a7bd4100e83b1d6b3 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 4 Oct 2021 15:22:21 +0100 Subject: [PATCH 03/14] :| --- .../Common/SpecflowTableHelper.cs | 10 +++++----- .../Settlement/Settlement.feature | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs b/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs index dc1e1782..b9c0bdf1 100644 --- a/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs +++ b/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs @@ -38,17 +38,17 @@ public static DateTime GetDateForDateString(String dateString, case "TODAY": return today.Date; case "YESTERDAY": - return today.AddDays(-1).Date; + return today.Date.AddDays(-1).Date; case "LASTWEEK": - return today.AddDays(-7).Date; + return today.Date.AddDays(-7).Date; case "NEXTWEEK": - return today.AddDays(7).Date; + return today.Date.AddDays(7).Date; case "LASTMONTH": - return today.AddMonths(-1).Date; + return today.Date.AddMonths(-1).Date; case "LASTYEAR": return today.AddYears(-1).Date; case "TOMORROW": - return today.AddDays(1).Date; + return today.Date.AddDays(1).Date; default: return DateTime.Parse(dateString); } diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature index 91ec227a..76a95357 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature @@ -143,7 +143,7 @@ Scenario: Process Settlement When I get the pending settlements the following information should be returned | SettlementDate | EstateName | NumberOfFees | - | Yesterday | Test Estate 1 | 1 | + | Yesterday | Test Estate 1 | 1 | When I process the settlement for 'Yesterday' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed From e9d6be8f9da8d790d44f8c18106646738e27de7c Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 4 Oct 2021 16:14:15 +0100 Subject: [PATCH 04/14] ... --- TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 9bb07b14..0b3f0981 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -924,7 +924,7 @@ private DateTime GetSettlementDate(DateTime now, { if (nextSettlementDate == "Yesterday") { - return now.Date.AddDays(-1).Date; + return now.Date.AddHours(-1).AddDays(-1).Date; } if (nextSettlementDate == "NextWeek") From 757bbbee783670a4dbfaeca1a8b8d0c45b00a99e Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 4 Oct 2021 16:28:14 +0100 Subject: [PATCH 05/14] :| --- TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 0b3f0981..07189047 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -898,7 +898,8 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB [When(@"I process the settlement for '([^']*)' on Estate '([^']*)' then (.*) fees are marked as settled and the settlement is completed")] public async Task WhenIProcessTheSettlementForOnEstateThenFeesAreMarkedAsSettledAndTheSettlementIsCompleted(String dateString, String estateName, Int32 numberOfFeesSettled) { - var settlementDate = SpecflowTableHelper.GetDateForDateString(dateString, DateTime.Now); + DateTime settlementDate = this.GetSettlementDate(DateTime.Now, dateString); + Console.WriteLine($"Settlement date is {settlementDate}"); EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); await this.TestingContext.DockerHelper.TransactionProcessorClient.ProcessSettlement(this.TestingContext.AccessToken, settlementDate, @@ -924,7 +925,7 @@ private DateTime GetSettlementDate(DateTime now, { if (nextSettlementDate == "Yesterday") { - return now.Date.AddHours(-1).AddDays(-1).Date; + return now.Date.AddDays(-1).Date; } if (nextSettlementDate == "NextWeek") From 43c3cc111a45befec048b55cb204747584d2d854 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Mon, 4 Oct 2021 16:55:44 +0100 Subject: [PATCH 06/14] . --- TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 07189047..48c84008 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -890,7 +890,7 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB estateDetails.EstateId, CancellationToken.None); - settlements.NumberOfFeesPendingSettlement.ShouldBe(numberOfFees); + settlements.NumberOfFeesPendingSettlement.ShouldBe(numberOfFees, $"Settlment date {settlementDate}"); }, TimeSpan.FromMinutes(3)); } } From 7f4618e7b2f8b5cb0ce6e12c15845e57f5278291 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 07:44:01 +0100 Subject: [PATCH 07/14] :| --- .github/workflows/pullrequest.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index dfec0962..a78e1479 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -34,3 +34,9 @@ jobs: - name: Run Integration Tests run: dotnet test "TransactionProcessor.IntegrationTests\TransactionProcessor.IntegrationTests.csproj" --filter Category=PRTest + + - uses: actions/upload-artifact@v2 + if: ${{ failure() }} + with: + name: tracelogs + path: /home/txnproc/trace/ \ No newline at end of file From e9e8a0dd6568096b7a87e1dab9e565d14962a1f5 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 09:15:06 +0100 Subject: [PATCH 08/14] :| --- .../Settlement/Settlement.feature | 2 +- .../Settlement/Settlement.feature.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature index 76a95357..8354822c 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature @@ -143,7 +143,7 @@ Scenario: Process Settlement When I get the pending settlements the following information should be returned | SettlementDate | EstateName | NumberOfFees | - | Yesterday | Test Estate 1 | 1 | + | Today | Test Estate 1 | 1 | When I process the settlement for 'Yesterday' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs index c8e5ea31..6b7116c6 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs @@ -895,7 +895,7 @@ public virtual void ProcessSettlement() "EstateName", "NumberOfFees"}); table84.AddRow(new string[] { - "Yesterday", + "Today", "Test Estate 1", "1"}); #line 144 From d52b764963b8e557be445b7310fefc65de14d337 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 09:51:49 +0100 Subject: [PATCH 09/14] :| --- .../Settlement/Settlement.feature | 2 +- .../Settlement/Settlement.feature.cs | 2 +- TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature index 8354822c..76a95357 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature @@ -143,7 +143,7 @@ Scenario: Process Settlement When I get the pending settlements the following information should be returned | SettlementDate | EstateName | NumberOfFees | - | Today | Test Estate 1 | 1 | + | Yesterday | Test Estate 1 | 1 | When I process the settlement for 'Yesterday' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs index 6b7116c6..c8e5ea31 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs @@ -895,7 +895,7 @@ public virtual void ProcessSettlement() "EstateName", "NumberOfFees"}); table84.AddRow(new string[] { - "Today", + "Yesterday", "Test Estate 1", "1"}); #line 144 diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 48c84008..1fa9654d 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -880,7 +880,7 @@ public async Task WhenIGetThePendingSettlementsTheFollowingInformationShouldBeRe EstateDetails estateDetails = this.TestingContext.GetEstateDetails(tableRow); String settlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "SettlementDate"); Int32 numberOfFees = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfFees"); - DateTime settlementDate = this.GetSettlementDate(DateTime.Now, settlementDateString); + DateTime settlementDate = this.GetSettlementDate(DateTime.Today, settlementDateString); var aggregateid = settlementDate.ToGuid(); await Retry.For(async () => { From 041343152a8a944652e7e50b70a83f1ef0ba3b89 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 11:08:40 +0100 Subject: [PATCH 10/14] :| --- .../Common/SpecflowTableHelper.cs | 10 +++++----- .../Shared/SharedSteps.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs b/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs index b9c0bdf1..dc1e1782 100644 --- a/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs +++ b/TransactionProcessor.IntegrationTests/Common/SpecflowTableHelper.cs @@ -38,17 +38,17 @@ public static DateTime GetDateForDateString(String dateString, case "TODAY": return today.Date; case "YESTERDAY": - return today.Date.AddDays(-1).Date; + return today.AddDays(-1).Date; case "LASTWEEK": - return today.Date.AddDays(-7).Date; + return today.AddDays(-7).Date; case "NEXTWEEK": - return today.Date.AddDays(7).Date; + return today.AddDays(7).Date; case "LASTMONTH": - return today.Date.AddMonths(-1).Date; + return today.AddMonths(-1).Date; case "LASTYEAR": return today.AddYears(-1).Date; case "TOMORROW": - return today.Date.AddDays(1).Date; + return today.AddDays(1).Date; default: return DateTime.Parse(dateString); } diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 1fa9654d..bd3a1f9f 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -925,17 +925,17 @@ private DateTime GetSettlementDate(DateTime now, { if (nextSettlementDate == "Yesterday") { - return now.Date.AddDays(-1).Date; + return now.AddDays(-1).Date; } if (nextSettlementDate == "NextWeek") { - return now.Date.AddHours(-1).AddDays(7).Date; + return now.AddDays(7).Date; } if (nextSettlementDate == "NextMonth") { - return now.Date.AddHours(-1).AddMonths(1).Date; + return now.AddMonths(1).Date; } return now.Date; From b3fe033196c02897f729d665ac6fef236f508bb9 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 12:40:27 +0100 Subject: [PATCH 11/14] :| --- .../Settlement/Settlement.feature | 4 ++-- .../Settlement/Settlement.feature.cs | 6 +++--- TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature index 76a95357..26f1223e 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature @@ -143,8 +143,8 @@ Scenario: Process Settlement When I get the pending settlements the following information should be returned | SettlementDate | EstateName | NumberOfFees | - | Yesterday | Test Estate 1 | 1 | + | Today | Test Estate 1 | 1 | - When I process the settlement for 'Yesterday' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed + When I process the settlement for 'Today' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs index c8e5ea31..1a2480e4 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs @@ -895,15 +895,15 @@ public virtual void ProcessSettlement() "EstateName", "NumberOfFees"}); table84.AddRow(new string[] { - "Yesterday", + "Today", "Test Estate 1", "1"}); #line 144 testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table84, "When "); #line hidden #line 148 - testRunner.When("I process the settlement for \'Yesterday\' on Estate \'Test Estate 1\' then 1 fees ar" + - "e marked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.When("I process the settlement for \'Today\' on Estate \'Test Estate 1\' then 1 fees are ma" + + "rked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden } this.ScenarioCleanup(); diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index bd3a1f9f..7bbfb936 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -881,6 +881,11 @@ public async Task WhenIGetThePendingSettlementsTheFollowingInformationShouldBeRe String settlementDateString = SpecflowTableHelper.GetStringRowValue(tableRow, "SettlementDate"); Int32 numberOfFees = SpecflowTableHelper.GetIntValue(tableRow, "NumberOfFees"); DateTime settlementDate = this.GetSettlementDate(DateTime.Today, settlementDateString); + if (Environment.GetEnvironmentVariable("CI") == Boolean.TrueString.ToLower()) + { + settlementDate = settlementDate.AddDays(-1); + } + var aggregateid = settlementDate.ToGuid(); await Retry.For(async () => { From 035ba23fb11234d025455e729a1291e308ed71fe Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 13:59:29 +0100 Subject: [PATCH 12/14] :| --- .../Settlement/Settlement.feature | 4 ++-- .../Settlement/Settlement.feature.cs | 6 +++--- TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature index 26f1223e..76a95357 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature @@ -143,8 +143,8 @@ Scenario: Process Settlement When I get the pending settlements the following information should be returned | SettlementDate | EstateName | NumberOfFees | - | Today | Test Estate 1 | 1 | + | Yesterday | Test Estate 1 | 1 | - When I process the settlement for 'Today' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed + When I process the settlement for 'Yesterday' on Estate 'Test Estate 1' then 1 fees are marked as settled and the settlement is completed diff --git a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs index 1a2480e4..c8e5ea31 100644 --- a/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Settlement/Settlement.feature.cs @@ -895,15 +895,15 @@ public virtual void ProcessSettlement() "EstateName", "NumberOfFees"}); table84.AddRow(new string[] { - "Today", + "Yesterday", "Test Estate 1", "1"}); #line 144 testRunner.When("I get the pending settlements the following information should be returned", ((string)(null)), table84, "When "); #line hidden #line 148 - testRunner.When("I process the settlement for \'Today\' on Estate \'Test Estate 1\' then 1 fees are ma" + - "rked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); + testRunner.When("I process the settlement for \'Yesterday\' on Estate \'Test Estate 1\' then 1 fees ar" + + "e marked as settled and the settlement is completed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); #line hidden } this.ScenarioCleanup(); diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 7bbfb936..c8bbf08e 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -883,7 +883,7 @@ public async Task WhenIGetThePendingSettlementsTheFollowingInformationShouldBeRe DateTime settlementDate = this.GetSettlementDate(DateTime.Today, settlementDateString); if (Environment.GetEnvironmentVariable("CI") == Boolean.TrueString.ToLower()) { - settlementDate = settlementDate.AddDays(-1); + settlementDate = settlementDate.AddDays(1); } var aggregateid = settlementDate.ToGuid(); @@ -911,6 +911,10 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.ProcessSettlem estateDetails.EstateId, CancellationToken.None); + if (Environment.GetEnvironmentVariable("CI") == Boolean.TrueString.ToLower()) + { + settlementDate = settlementDate.AddDays(1); + } await Retry.For(async () => { SettlementResponse settlement = From 17a9fbeeda8b24c4602eeac3e843cca6cd0572c5 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 14:10:28 +0100 Subject: [PATCH 13/14] . --- TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index c8bbf08e..4d4108a5 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -903,7 +903,7 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB [When(@"I process the settlement for '([^']*)' on Estate '([^']*)' then (.*) fees are marked as settled and the settlement is completed")] public async Task WhenIProcessTheSettlementForOnEstateThenFeesAreMarkedAsSettledAndTheSettlementIsCompleted(String dateString, String estateName, Int32 numberOfFeesSettled) { - DateTime settlementDate = this.GetSettlementDate(DateTime.Now, dateString); + DateTime settlementDate = this.GetSettlementDate(DateTime.Today, dateString); Console.WriteLine($"Settlement date is {settlementDate}"); EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); await this.TestingContext.DockerHelper.TransactionProcessorClient.ProcessSettlement(this.TestingContext.AccessToken, From 006489d9dd2c157baa0acab15d84bb833f07c0ba Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 5 Oct 2021 14:30:12 +0100 Subject: [PATCH 14/14] :| --- .../Shared/SharedSteps.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 4d4108a5..47d230b4 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -904,17 +904,17 @@ await this.TestingContext.DockerHelper.TransactionProcessorClient.GetSettlementB public async Task WhenIProcessTheSettlementForOnEstateThenFeesAreMarkedAsSettledAndTheSettlementIsCompleted(String dateString, String estateName, Int32 numberOfFeesSettled) { DateTime settlementDate = this.GetSettlementDate(DateTime.Today, dateString); - Console.WriteLine($"Settlement date is {settlementDate}"); + if (Environment.GetEnvironmentVariable("CI") == Boolean.TrueString.ToLower()) + { + settlementDate = settlementDate.AddDays(1); + } + EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); await this.TestingContext.DockerHelper.TransactionProcessorClient.ProcessSettlement(this.TestingContext.AccessToken, settlementDate, estateDetails.EstateId, CancellationToken.None); - if (Environment.GetEnvironmentVariable("CI") == Boolean.TrueString.ToLower()) - { - settlementDate = settlementDate.AddDays(1); - } await Retry.For(async () => { SettlementResponse settlement =