Updated Request Matching (markdown)

Stef Heyenrath
2019-08-29 07:46:23 +02:00
parent ee48c20acd
commit 89f4c87d31

@@ -14,6 +14,7 @@ The following paragraphs describe in detail which matchers can be used.
At this moment these matchers are supported:
* [ExactMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#exact-matcher-exactmatcher)
* [LinqMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#dynamic-linq-linqmatcher)
* CSharpCodeMatcher
* [JsonMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#json-jsonmatcher)
* [JsonPathMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#json-path-jsonpathmatcher)
* [JmesPathMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#jmes-path-jmespathmatcher)
@@ -115,6 +116,56 @@ server
}
```
## CSharp Code (CSharpCodeMatcher)
*Advanced!* With this matcher you can use complex C# code to match an JObject or string value.
* Note that this functionality will only work if enabled in the settings (`AllowCSharpCodeMatcher = true`).
* The argument-name from the string or JObject to match will be `it`.
#### C# option
```csharp
var server = FluentMockServer.Start();
server
.Given(Request.Create().WithPath("/cs")
.WithParam("from", new CSharpCodeMatcher("return it == \"x\";")))
.RespondWith(Response.Create()
.WithBody("cs match")
);
```
#### JSON Mapping option
``` js
{
"Guid": "67ae335b-5d79-42dc-8ca7-236280ab9211",
"Priority": 0,
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/cs"
}
]
},
"Params": [
{
"Name": "from",
"Matchers": [
{
"Name": "CSharpCodeMatcher",
"Pattern": "return it == \"x\";"
}
]
}
],
"Body": {}
},
"Response": {
"Body": "cs match"
}
}
```
## JSON (JsonMatcher)
Checks if a JSON object (or JSON as string) is DeepEqual.