mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-07-18 11:01:23 +02:00
Updated Request Matching (markdown)
+11
-5
@@ -420,7 +420,6 @@ Hi WM
|
|||||||
```csharp
|
```csharp
|
||||||
var server = FluentMockServer.Start();
|
var server = FluentMockServer.Start();
|
||||||
server
|
server
|
||||||
.AllowPartialMatching()
|
|
||||||
.Given(
|
.Given(
|
||||||
Request.Create().WithPath("/reg").UsingGet()
|
Request.Create().WithPath("/reg").UsingGet()
|
||||||
.WithBody(new SimMetricsMatcher("The cat walks in the street."));
|
.WithBody(new SimMetricsMatcher("The cat walks in the street."));
|
||||||
@@ -437,9 +436,10 @@ Hello
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### WildcardMatching (WildcardMatch)
|
### WildcardMatching (WildcardMatcher)
|
||||||
WildcardMatching is mostly used for Path and Url matching. This matcher allows a ? for a single character and * for any characters.
|
WildcardMatching is mostly used for Path and Url matching. This matcher allows a ? for a single character and * for any characters.
|
||||||
|
|
||||||
|
#### Option 1
|
||||||
```csharp
|
```csharp
|
||||||
var server = FluentMockServer.Start();
|
var server = FluentMockServer.Start();
|
||||||
server
|
server
|
||||||
@@ -447,9 +447,15 @@ server
|
|||||||
.RespondWith(Response.Create().WithBody("Hello"));
|
.RespondWith(Response.Create().WithBody("Hello"));
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
#### Option 2
|
||||||
// matching
|
```csharp
|
||||||
Url like /somebody and /something
|
var server = FluentMockServer.Start();
|
||||||
|
server
|
||||||
|
.Given(
|
||||||
|
Request.Create().WithPath("/wc").UsingGet()
|
||||||
|
.WithBody(new WildcardMatcher("x."));
|
||||||
|
)
|
||||||
|
.RespondWith(Response.Create().WithBody("Matched with *"));
|
||||||
```
|
```
|
||||||
|
|
||||||
### Reversing the match behaviour with `MatchBehaviour.RejectOnMatch`
|
### Reversing the match behaviour with `MatchBehaviour.RejectOnMatch`
|
||||||
|
|||||||
Reference in New Issue
Block a user