From 3f370f32ed6605b359f92ab1027e4956f6333a44 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sat, 16 Dec 2023 13:23:18 +0100 Subject: [PATCH] sc --- .../Server/IRespondWithAProvider.cs | 28 +++++++++---------- .../Server/RespondWithAProvider.cs | 14 +++++----- .../Server/WireMockServer.Fluent.cs | 2 +- .../WireMockServerTests.WithParam.cs | 14 ++++------ 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/WireMock.Net/Server/IRespondWithAProvider.cs b/src/WireMock.Net/Server/IRespondWithAProvider.cs index 5874592dc..eb65cf333 100644 --- a/src/WireMock.Net/Server/IRespondWithAProvider.cs +++ b/src/WireMock.Net/Server/IRespondWithAProvider.cs @@ -26,6 +26,13 @@ public interface IRespondWithAProvider /// The . IRespondWithAProvider WithGuid(Guid guid); + /// + /// Define a unique identifier for this mapping. + /// + /// The unique identifier. + /// The . + IRespondWithAProvider WithGuid(string guid); + /// /// Define a unique identifier for this mapping. /// @@ -33,6 +40,13 @@ public interface IRespondWithAProvider /// The . IRespondWithAProvider DefineGuid(Guid guid); + /// + /// Define a unique identifier for this mapping. + /// + /// The unique identifier. + /// The . + IRespondWithAProvider DefineGuid(string guid); + /// /// Define the TimeSettings for this mapping. /// @@ -61,20 +75,6 @@ public interface IRespondWithAProvider /// The . IRespondWithAProvider WithPath(string path); - /// - /// Define a unique identifier for this mapping. - /// - /// The unique identifier. - /// The . - IRespondWithAProvider WithGuid(string guid); - - /// - /// Define a unique identifier for this mapping. - /// - /// The unique identifier. - /// The . - IRespondWithAProvider DefineGuid(string guid); - /// /// Define the priority for this mapping. /// diff --git a/src/WireMock.Net/Server/RespondWithAProvider.cs b/src/WireMock.Net/Server/RespondWithAProvider.cs index efaa8adb4..46d657352 100644 --- a/src/WireMock.Net/Server/RespondWithAProvider.cs +++ b/src/WireMock.Net/Server/RespondWithAProvider.cs @@ -153,12 +153,6 @@ public IRespondWithAProvider WithGuid(string guid) return WithGuid(Guid.Parse(guid)); } - /// - public IRespondWithAProvider DefineGuid(string guid) - { - return WithGuid(guid); - } - /// public IRespondWithAProvider WithGuid(Guid guid) { @@ -173,6 +167,12 @@ public IRespondWithAProvider DefineGuid(Guid guid) return WithGuid(guid); } + /// + public IRespondWithAProvider DefineGuid(string guid) + { + return WithGuid(guid); + } + /// public IRespondWithAProvider WithTitle(string title) { @@ -189,7 +189,7 @@ public IRespondWithAProvider WithDescription(string description) return this; } - /// + /// public IRespondWithAProvider WithPath(string path) { _path = path; diff --git a/src/WireMock.Net/Server/WireMockServer.Fluent.cs b/src/WireMock.Net/Server/WireMockServer.Fluent.cs index 5c74b80dd..a7a15d289 100644 --- a/src/WireMock.Net/Server/WireMockServer.Fluent.cs +++ b/src/WireMock.Net/Server/WireMockServer.Fluent.cs @@ -27,7 +27,7 @@ public IRespondWithAProvider Given(IRequestMatcher requestMatcher, bool saveToFi /// Optional boolean to indicate if this mapping should be saved as static mapping file. /// The . [PublicAPI] - public IRespondWithAProvider WithRequest(Action action, bool saveToFile = false) + public IRespondWithAProvider WhenRequest(Action action, bool saveToFile = false) { Guard.NotNull(action); diff --git a/test/WireMock.Net.Tests/WireMockServerTests.WithParam.cs b/test/WireMock.Net.Tests/WireMockServerTests.WithParam.cs index 3d7645800..3d48a26e3 100644 --- a/test/WireMock.Net.Tests/WireMockServerTests.WithParam.cs +++ b/test/WireMock.Net.Tests/WireMockServerTests.WithParam.cs @@ -27,7 +27,7 @@ public async Task WireMockServer_WithParam_QueryParameterMultipleValueSupport_No }; var server = WireMockServer.Start(settings); server - .WithRequest(r => r + .WhenRequest(r => r .UsingGet() .WithPath("/foo") .WithParam("query", queryValue) @@ -53,12 +53,12 @@ public async Task WireMockServer_WithParam_MultiValueComma() var queryValue = "1,2,3"; var server = WireMockServer.Start(); server - .WithRequest(r => r + .WhenRequest(r => r .UsingGet() .WithPath("/foo") .WithParam("query", "1", "2", "3") ) - .RespondWithOK(); + .RespondWithStatusCode(200); // Act var requestUri = new Uri($"http://localhost:{server.Port}/foo?query={queryValue}"); @@ -81,9 +81,7 @@ public async Task WireMockServer_WithParam_RejectOnMatch_OnNonMatchingParam_Shou .WithParam("delta_from", MatchBehaviour.RejectOnMatch) .UsingGet() ) - .RespondWith( - Response.Create() - ); + .RespondWithOK(); // Act var requestUri = new Uri($"http://localhost:{server.Port}/v1/person/workers?showsourcesystem=true&count=700&page=1§ions=personal%2Corganizations%2Cemployment"); @@ -106,9 +104,7 @@ public async Task WireMockServer_WithParam_AcceptOnMatch_OnNonMatchingParam_Shou .WithParam("delta_from") .UsingGet() ) - .RespondWith( - Response.Create() - ); + .RespondWithStatusCode("300"); // Act var requestUri = new Uri($"http://localhost:{server.Port}/v1/person/workers?showsourcesystem=true&count=700&page=1§ions=personal%2Corganizations%2Cemployment");