You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
7
7
## [0.10] - unplanned
8
+
### Deprecated
9
+
-`ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string, bool)` and `ShouldHaveMadeRequestsTo(this TestableHttpMessageHandler, string, bool, int)` have been deprecated. CaseInsensitivity is controlled by the `UriPatternMatchingOptions` that can be set on the `TestableHttpMessageHandler`.
10
+
-`WithRequestUri(this IHttpRequestMessagesCheck, string, bool)` and `WithRequestUri(this IHttpRequestMessagesCheck, string, bool, int)` have been deprecated. CaseInsensitivity is controlled by the `UriPatternMatchingOptions` that can be set on the `TestableHttpMessageHandler`.
11
+
-`WithQueryString` has been deprecated, since `ShouldHaveMadeRequestTo` and `WithRequestUri` now properly support querystrings.
12
+
8
13
### Removed
9
14
-`TestableHttpMessageHandler.SimulateTimeout` has been removed, and can be replaced with `RespondWith(Responses.Timeout())`.
10
15
-`TestableHttpMessageHandler.RespondWith(Func<HttpRequestMessage, HttpResponseMessage>)` has been removed, it's functionality is replaced by IResponse.
11
16
-`RespondWith(this TestableHttpMessageHandler, HttpResponseMessage)` has been removed, the response is modified with every call, so it doesn't work reliably and is different from how HttpClientHandler works, which creates a HttpResponseMessage for every request.
12
17
-`HttpResponseMessageBuilder` and `RespondWith(this TestableHttpMessageHandler, HttpResponseMessageBuilder)` has been removed, it's functionality can be replaced with ConfiguredResponse or a custom IResponse.
13
18
19
+
### Added
20
+
- URI patterns now support query parameters and by default will use the unescaped values, note that the order is still important.
21
+
- URI pattern parsing is extended to be able to parse most URI's.
22
+
23
+
### Changed
24
+
- Use the same parser for the assertion methods `WithRequestUri` (which is used by `ShouldHaveMadeRequestsTo`) as for the RoutingResponse functionality.
25
+
-`RouteParserException` has been renamed to `UriPatternParserException`.
26
+
- Renamed `RoutingOptions` to `UriPatternMatchingOptions`.
27
+
14
28
## [0.9] - 2022-11-25
15
29
### Deprecated
16
30
-`Responses.NoContent()` has been deprecated, since it doesn't fit well with the rest of the API. Please use `Responses.StatusCode(HttpStatusCode.NoContent)` instead.
More examples can be found in the [IntegrationTests project](test/TestableHttpClient.IntegrationTests)
38
38
39
+
## URI Patterns
40
+
41
+
TestableHttpClient supports URI patterns in several places, mainly in:
42
+
- Response routing, where an URI pattern is used for matching the request URI to a response
43
+
- Assertions, where requests can be asserted against an URI pattern.
44
+
45
+
URI patterns are based on URI's as specified in [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986), but allow the wildcard character `*` to specify optional parts of an URI.
46
+
47
+
An URI contains several components:
48
+
- The scheme of an URI is optional, but when given it should end with `://`. When not given `*://` is assumed.
49
+
- User Information (`username:password@`) is ignored and is not checked at all.
50
+
- The host is optional and when not given `*` is assumed. Both IP addresses and registered names are supported.
51
+
- The port is optional, but when ':' is provided after host, it should have a value.
52
+
- The path is optional, but should start with a `/`. When `/` is given, it can be followed by a `*` to match it with any path.
53
+
- Query parameters are optional, when given it should start with a `?`.
54
+
- Fragments are ignored, but should start with a `#`.
55
+
56
+
URI patterns differ from URI's in the following ways:
57
+
- Any character is allowed, for example: `myhost:myport` is a valid URI pattern, but not a valid URI. (and this will never match).
58
+
- No encoding is performed, and patterns are matched against the unescaped values of an URI.
59
+
- Patterns are not normalized, so a path pattern `/test/../example` will not work.
60
+
61
+
Some examples:
62
+
63
+
Uri pattern | Matches
64
+
------------|--------
65
+
*|Matches any URL
66
+
\*://\*/\*?\* | Matches any URL
67
+
/get | Matches any URL that uses the path `/get`
68
+
http*://* | Matches any URL that uses the scheme `http` or `https` (or any other scheme that starts with `http`)
69
+
localhost:5000 | Matches any URL that uses localhost for the host and port 5000, no matter what scheme or path is used.
70
+
71
+
## Controlling the behaviour of pattern matching
72
+
73
+
TestableHttpClient has several options available that let you control different parts of the library. These options can be found on
74
+
the `TestableHttpMessageHandler.Options` and are passed to the `HttpRepsonseContext` and the `IHttpRequestMessagesCheck`.
75
+
The options include:
76
+
-`JsonSerializerOptions` for controlling the serialization of json content
77
+
-`UriPatternMatchingOptions` for controlling how the URI pattern matching works.
78
+
39
79
## Supported .NET versions
40
80
41
81
TestableHttpClient is build as a netstandard2.0 library, so theoretically it can work on every .NET version that support netstandard2.0.
returncheck.WithFilter(x =>x.RequestUriis not null&&uriPattern.Matches(x.RequestUri,check.Options.UriPatternMatchingOptions),expectedNumberOfRequests,condition);
49
+
}
50
+
51
+
[Obsolete("Please use an overload without the 'ignoreCase', since ignoring casing is now controlled globally.")]
0 commit comments