From ea0abde8c6afb9d3381ccdd24f3dc39023be1b39 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Mon, 13 Feb 2017 18:17:52 +0100 Subject: [PATCH] Updated Stubbing (markdown) --- Stubbing.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) 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.