Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Dec 16, 2023
1 parent 5d6b530 commit 124959b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions WireMock.Net Solution.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MD/@EntryIndexedValue">MD5</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OK/@EntryIndexedValue">OK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OPTIONS/@EntryIndexedValue">OPTIONS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PATCH/@EntryIndexedValue">PATCH</s:String>
Expand Down
28 changes: 28 additions & 0 deletions src/WireMock.Net/Server/IRespondWithAProvider.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Net;
using WireMock.Models;
using WireMock.ResponseBuilders;
using WireMock.ResponseProviders;
using WireMock.Settings;
using WireMock.Types;

namespace WireMock.Server;
Expand Down Expand Up @@ -92,6 +94,32 @@ public interface IRespondWithAProvider
/// <param name="action">The action to use the fluent <see cref="IResponseBuilder"/>.</param>
void RespondWith(Action<IResponseBuilder> action);

/// <summary>
/// RespondWith a status code 200 (OK);
/// </summary>
void RespondWithOK();

/// <summary>
/// RespondWith a status code.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="WireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// </summary>
/// <param name="code">The code.</param>
void RespondWithStatusCode(int code);

/// <summary>
/// RespondWith a status code.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="WireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// </summary>
/// <param name="code">The code.</param>
void RespondWithStatusCode(string code);

/// <summary>
/// RespondWith a status code.
/// By default all status codes are allowed, to change this behaviour, see <inheritdoc cref="WireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>.
/// </summary>
/// <param name="code">The code.</param>
void RespondWithStatusCode(HttpStatusCode code);

/// <summary>
/// Sets the the scenario.
/// </summary>
Expand Down
33 changes: 33 additions & 0 deletions src/WireMock.Net/Server/RespondWithAProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
using System;
using System.Collections.Generic;
using System.Net;
using Stef.Validation;
using WireMock.Matchers.Request;
using WireMock.Models;
Expand Down Expand Up @@ -107,6 +108,38 @@ public void RespondWith(Action<IResponseBuilder> action)
RespondWith(responseBuilder);
}

/// <inheritdoc />
public void RespondWithOK()
{
var responseBuilder = Response.Create();

RespondWith(responseBuilder);
}

/// <inheritdoc />
public void RespondWithStatusCode(int code)
{
var responseBuilder = Response.Create().WithStatusCode(code);

RespondWith(responseBuilder);
}

/// <inheritdoc />
public void RespondWithStatusCode(string code)
{
var responseBuilder = Response.Create().WithStatusCode(code);

RespondWith(responseBuilder);
}

/// <inheritdoc />
public void RespondWithStatusCode(HttpStatusCode code)
{
var responseBuilder = Response.Create().WithStatusCode(code);

RespondWith(responseBuilder);
}

/// <inheritdoc />
public IRespondWithAProvider WithData(object data)
{
Expand Down
3 changes: 2 additions & 1 deletion test/WireMock.Net.Tests/WireMockServerTests.WithParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public async Task WireMockServer_WithParam_MultiValueComma()
.UsingGet()
.WithPath("/foo")
.WithParam("query", "1", "2", "3")
);
)
.RespondWithOK();

// Act
var requestUri = new Uri($"http://localhost:{server.Port}/foo?query={queryValue}");
Expand Down

0 comments on commit 124959b

Please sign in to comment.