diff --git a/Stubbing.md b/Stubbing.md index b79c8a8..01238d6 100644 --- a/Stubbing.md +++ b/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.