mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 09:18:55 +02:00
Updated Stubbing (markdown)
34
Stubbing.md
34
Stubbing.md
@@ -103,16 +103,46 @@ Will match xml below:
|
|||||||
The RegexMatcher can be used to match using a regular expression.
|
The RegexMatcher can be used to match using a regular expression.
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
// todo example
|
var server = FluentMockServer.Start();
|
||||||
|
server
|
||||||
|
.Given(
|
||||||
|
Request.Create().WithPath("/reg").UsingGet()
|
||||||
|
.WithBody(new RegexMatcher("H.*o"));
|
||||||
|
)
|
||||||
|
.RespondWith(Response.WithBody("Hello matched with RegexMatcher"));
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
// matching
|
||||||
|
Hello World
|
||||||
|
|
||||||
|
// not matching
|
||||||
|
Hi WM
|
||||||
```
|
```
|
||||||
|
|
||||||
### Similarity Metric Matching
|
### Similarity Metric Matching
|
||||||
[SimMetrics.Net](https://github.com/StefH/SimMetrics.Net) is used as a Similarity Metric Library, e.g. from edit distance's (Levenshtein, Gotoh, Jaro etc) to other metrics, (e.g Soundex, Chapman).
|
[SimMetrics.Net](https://github.com/StefH/SimMetrics.Net) is used as a Similarity Metric Library, e.g. from edit distance's (Levenshtein, Gotoh, Jaro etc) to other metrics, (e.g Soundex, Chapman).
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
// todo example
|
var server = FluentMockServer.Start();
|
||||||
|
server
|
||||||
|
.AllowPartialMatching()
|
||||||
|
.Given(
|
||||||
|
Request.Create().WithPath("/reg").UsingGet()
|
||||||
|
.WithBody(new SimMetricsMatcher("The cat walks in the street."));
|
||||||
|
)
|
||||||
|
.RespondWith(Response.WithBody("Matched with SimMetricsMatcher"));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
// matching with distance 0.793
|
||||||
|
The car drives in the street.
|
||||||
|
|
||||||
|
// matching with distance 0.071
|
||||||
|
Hello
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### WildcardMatching
|
### WildcardMatching
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user