-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update + add fluent builder methods (#1042)
* Update some fluent builder methods * fix * sc * ThenRespondWith * // Copyright © WireMock.Net
- Loading branch information
Showing
6 changed files
with
168 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright © WireMock.Net | ||
|
||
using System; | ||
using JetBrains.Annotations; | ||
using Stef.Validation; | ||
using WireMock.Matchers.Request; | ||
using WireMock.RequestBuilders; | ||
|
||
namespace WireMock.Server; | ||
|
||
public partial class WireMockServer | ||
{ | ||
/// <summary> | ||
/// Given | ||
/// </summary> | ||
/// <param name="requestMatcher">The request matcher.</param> | ||
/// <param name="saveToFile">Optional boolean to indicate if this mapping should be saved as static mapping file.</param> | ||
/// <returns>The <see cref="IRespondWithAProvider"/>.</returns> | ||
[PublicAPI] | ||
public IRespondWithAProvider Given(IRequestMatcher requestMatcher, bool saveToFile = false) | ||
{ | ||
return _mappingBuilder.Given(requestMatcher, saveToFile); | ||
} | ||
|
||
/// <summary> | ||
/// WhenRequest | ||
/// </summary> | ||
/// <param name="action">The action to use the fluent <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="saveToFile">Optional boolean to indicate if this mapping should be saved as static mapping file.</param> | ||
/// <returns>The <see cref="IRespondWithAProvider"/>.</returns> | ||
[PublicAPI] | ||
public IRespondWithAProvider WhenRequest(Action<IRequestBuilder> action, bool saveToFile = false) | ||
{ | ||
Guard.NotNull(action); | ||
|
||
var requestBuilder = Request.Create(); | ||
|
||
action(requestBuilder); | ||
|
||
return Given(requestBuilder, saveToFile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters