From a41a16a40aae0eb539dc8151b45927b81a3625ba Mon Sep 17 00:00:00 2001 From: Marcin Celej Date: Thu, 16 May 2024 09:53:12 +0200 Subject: [PATCH] #18: Synergy.Web.Api.Testing: Added sample how to ingnore request header when comparing HTTP operation with its saved pattern. --- .../Patterns/S01_E01_GetEmptyListOfUsers.json | 2 +- .../Users/UserScenario.cs | 1 + .../Users/Users.md | 23 ++++++++----------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S01_E01_GetEmptyListOfUsers.json b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S01_E01_GetEmptyListOfUsers.json index 2c2f2e7..00ed822 100644 --- a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S01_E01_GetEmptyListOfUsers.json +++ b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S01_E01_GetEmptyListOfUsers.json @@ -9,7 +9,7 @@ "description": "Get list of users", "method": "GET /api/v1/users", "headers": { - "test": "header" + "test": "header1" } }, "response": { diff --git a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/UserScenario.cs b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/UserScenario.cs index 0925f75..1ac2506 100644 --- a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/UserScenario.cs +++ b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/UserScenario.cs @@ -55,6 +55,7 @@ private void GetEmptyListOfUsers() .ShouldBe(ApiConventionFor.GetListOfResources()) .ShouldBe( this.EqualToPattern("/Patterns/S01_E01_GetEmptyListOfUsers.json") + .Ignore(Ignore.RequestHeaders("test")) .Expected("Manual: Empty users list is returned") ); } diff --git a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md index 5c6532e..b0e6ef2 100644 --- a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md +++ b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md @@ -20,7 +20,7 @@ - Request ``` GET /api/v1/users -test: header +test: header1 ``` - Response @@ -57,9 +57,8 @@ Content-Length: 19 - Request ``` POST /api/v1/users -Content-Type: application/json; charset=utf-8 -Content-Length: 40 test: header +Content-Type: application/json; charset=utf-8 { "Login": { "Value": "marcin@synergy.com" @@ -70,16 +69,17 @@ test: header - Response ``` HTTP/1.1 201 Created -Location: http://localhost/api/v1/users/102a023150d94b1b99dbfbd5d6a695d8 +Location: http://localhost/api/v1/users/0dd576b44c7a40a4884cc7512272e751 api-supported-versions: 1.0 Content-Type: application/json; charset=utf-8 -Content-Length: 129 +Content-Length: 182 { "user": { - "id": "102a023150d94b1b99dbfbd5d6a695d8", + "id": "0dd576b44c7a40a4884cc7512272e751", "login": { "value": "marcin@synergy.com" - } + }, + "created": "2024-05-13T13:19:15.8420304+02:00" } } ``` @@ -262,9 +262,8 @@ Content-Length: 207 - Request ``` POST /api/v1/users -Content-Type: application/json; charset=utf-8 -Content-Length: 14 test: header +Content-Type: application/json; charset=utf-8 { "login": null } @@ -305,9 +304,8 @@ Content-Length: 351 - Request ``` POST /api/v1/users -Content-Type: application/json; charset=utf-8 -Content-Length: 12 test: header +Content-Type: application/json; charset=utf-8 { "login": "" } @@ -348,9 +346,8 @@ Content-Length: 349 - Request ``` POST /api/v1/users -Content-Type: application/json; charset=utf-8 -Content-Length: 14 test: header +Content-Type: application/json; charset=utf-8 { "login": " " }