feat!: add new overload to match RequestUri, accepting Matches
#201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



This PR adds a new type
Matches(see below) and adds a new overloadRequestMatchingExtensions.RequestUri(RequestMatching, Matches).Relates to #112
The behavior of the sibling overload accepting a string
RequestMatchingExtensions.RequestUri(RequestMatching, string)has now changed. It now no longer infers a wildcard match if the input string contains an asterisk '*'. It now only expects relative or absolute URI's and will match them exactly as before.Unfortunately, changing the behavior will cause friction amongst users that have used wildcards in their tests, but I see no other way to transition to this new API.
To perform wildcard matches, it must now be explicitly provided via the overload accepting a
Matchestype, eg. usingMatches.Wildcard("some*thing"). By using this explicit approach, we give users full control over how a request URI can be matched, and remove the ambiguity that was present with the string/wildcard inference. With the new API users can even use custom expression, regexes, etc.Matches struct
The new
Matchesstruct encapsulates string matching, so there is one unified API that can be used internally my MockHttp to match request URI's but also in the future headers, and URI components separately (eg. query string, path, authority, etc.).The
Matchestype provides several helpers:*:The following are less useful for request URI matching, but in the future the
Matchestype will also support matching query string and header key value pairs, which is where these will shine.Operators
The
Matchestype has several operator implementations, which also allows mixing different pattern styles:Implicit conversion
stringimplicitly converts toMatchesusingMatches.Exactly(..)ToString
When calling
ToString(), returns the provided pattern value.