Updated Request Matching (markdown)

Stef Heyenrath
2019-08-27 18:09:30 +02:00
parent f2491c7001
commit d6372c6247
+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`