mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-25 18:25:10 +01: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.
|
||||
|
||||
```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
|
||||
[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
|
||||
// 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 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