From e97324351206968edcf7803e0fa0fb45c7f8f691 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Thu, 15 May 2025 18:48:05 +0100 Subject: [PATCH] Enhance error handling in estate retrieval process - Updated `WhenIGetTheEstateAnErrorIsReturned` method in `TransactionProcessorSteps` to accept an `errorStatus` parameter for dynamic error handling. - Modified `Estate.feature` scenarios to specify exact error types returned, improving clarity in test expectations. - Adjusted `Estate.feature.cs` to align with updated feature scenarios, ensuring correct interpretation by the test runner. - Refactored `SharedSteps.cs` to replace the old error handling method with a new one that accommodates the `errorStatus` parameter. --- .../TransactionProcessorSteps.cs | 5 +++-- .../Features/Estate.feature | 4 ++-- .../Features/Estate.feature.cs | 4 ++-- .../Shared/SharedSteps.cs | 13 ++++++++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs index 38694169..ed09d452 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs @@ -995,12 +995,13 @@ public async Task WhenIGetTheEstateTheEstateSecurityUserDetailsAreReturnedAsFoll } } - public async Task WhenIGetTheEstateAnErrorIsReturned(String accessToken, String estateName, List estateDetailsList) + public async Task WhenIGetTheEstateAnErrorIsReturned(String accessToken, String estateName, List estateDetailsList, String errorStatus) { Guid estateId = Guid.NewGuid(); Result? result = await this.TransactionProcessorClient.GetEstate(accessToken, estateId, CancellationToken.None).ConfigureAwait(false); result.IsSuccess.ShouldBeFalse(); - result.Status.ShouldBe(ResultStatus.NotFound); + ResultStatus status = Enum.Parse(errorStatus); + result.Status.ShouldBe(status); } public async Task WhenIRemoveTheOperatorFromEstateTheOperatorIsRemoved(String accessToken, List estateDetailsList, String estateName, String operatorName) diff --git a/TransactionProcessor.IntegrationTests/Features/Estate.feature b/TransactionProcessor.IntegrationTests/Features/Estate.feature index d802eb3c..826b035c 100644 --- a/TransactionProcessor.IntegrationTests/Features/Estate.feature +++ b/TransactionProcessor.IntegrationTests/Features/Estate.feature @@ -50,7 +50,7 @@ Scenario: Get Estate | EmailAddress | | estateuser1@testestate1.co.uk | | estateuser2@testestate1.co.uk | - When I get the estate "Test Estate 2" an error is returned + When I get the estate "Test Estate 2" a "NotFound" error is returned Given I am logged in as "estateuser1@testestate1.co.uk" with password "123456" for Estate "Test Estate 1" with client "estateClient" When I get the estate "Test Estate 1" the estate details are returned as follows | EstateName | @@ -63,7 +63,7 @@ Scenario: Get Estate | EmailAddress | | estateuser1@testestate1.co.uk | | estateuser2@testestate1.co.uk | - When I get the estate "Test Estate 2" an error is returned + When I get the estate "Test Estate 2" a "Failure" error is returned Scenario: Update Estate Given I have created the following estates diff --git a/TransactionProcessor.IntegrationTests/Features/Estate.feature.cs b/TransactionProcessor.IntegrationTests/Features/Estate.feature.cs index b6d36efb..22389b9e 100644 --- a/TransactionProcessor.IntegrationTests/Features/Estate.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/Estate.feature.cs @@ -259,7 +259,7 @@ await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate securi " follows", ((string)(null)), table36, "When "); #line hidden #line 53 - await testRunner.WhenAsync("I get the estate \"Test Estate 2\" an error is returned", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); + await testRunner.WhenAsync("I get the estate \"Test Estate 2\" a \"NotFound\" error is returned", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden #line 54 await testRunner.GivenAsync("I am logged in as \"estateuser1@testestate1.co.uk\" with password \"123456\" for Esta" + @@ -293,7 +293,7 @@ await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate securi " follows", ((string)(null)), table39, "When "); #line hidden #line 66 - await testRunner.WhenAsync("I get the estate \"Test Estate 2\" an error is returned", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); + await testRunner.WhenAsync("I get the estate \"Test Estate 2\" a \"Failure\" error is returned", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden } await this.ScenarioCleanupAsync(); diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 8d654026..527d66b7 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -467,12 +467,19 @@ public async Task WhenIGetTheEstateTheEstateSecurityUserDetailsAreReturnedAsFoll await this.TransactionProcessorSteps.WhenIGetTheEstateTheEstateSecurityUserDetailsAreReturnedAsFollows(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates, securityUsers); } - [When(@"I get the estate ""(.*)"" an error is returned")] - public async Task WhenIGetTheEstateAnErrorIsReturned(String estateName) + //[When(@"I get the estate ""(.*)"" an error is returned")] + //public async Task WhenIGetTheEstateAnErrorIsReturned(String estateName) + //{ + // await this.TransactionProcessorSteps.WhenIGetTheEstateAnErrorIsReturned(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates); + //} + + [When("I get the estate {string} a {string} error is returned")] + public async Task WhenIGetTheEstateAErrorIsReturned(String estateName, string errorStatus) { - await this.TransactionProcessorSteps.WhenIGetTheEstateAnErrorIsReturned(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates); + await this.TransactionProcessorSteps.WhenIGetTheEstateAnErrorIsReturned(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates, errorStatus); } + [Given(@"I am logged in as ""(.*)"" with password ""(.*)"" for Estate ""(.*)"" with client ""(.*)""")] public async Task GivenIAmLoggedInAsWithPasswordForEstate(String username, String password,