mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 00:38:28 +02:00
Updated Request Matching (markdown)
@@ -14,6 +14,7 @@ The following paragraphs describe in detail which matchers can be used.
|
|||||||
At this moment these matchers are supported:
|
At this moment these matchers are supported:
|
||||||
* [ExactMatcher](https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#exact-matcher-exactmatcher)
|
* [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)
|
* [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)
|
* [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)
|
* [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)
|
* [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)
|
## JSON (JsonMatcher)
|
||||||
Checks if a JSON object (or JSON as string) is DeepEqual.
|
Checks if a JSON object (or JSON as string) is DeepEqual.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user