Skip to content

[RFC] Removal of IHttpRequestMessageCheck and chaining assertions in favor of a RequestBuilder and (later) Request #330

Description

@dnperfors

Up until now you could assert requests using (extension) methods using ShouldHaveMadeRequests and ShouldHaveMadeRequestsTo. For example:

handler.ShouldHaveMadeRequests().WitMethod(HttpMethod.Get).WithRequestUri("https://github.com/testablehttpclient");

Each method will do it's own assertion and it will generate an error message which doesn't say a lot, although this will be improved in version 0.12 where you will get the message that the GET request did not match, or that the GET request to the uri:... did not match.

In version 0.12 I also added new methods to assert requests in the form of

handler.ShouldHaveMadeRequests(x => x.WithMethod(HttpMethod.Get).WithRequestUri("https://github.com/testablehttpclient"))

With this new message, the whole request can be asserted at once, which will lead to clearer error messages.

I believe that this new interface will be more concise, although it can still be improved. Therefor I will deprecate the IHttpRequestMessageCheck interface in version 0.13 in favor of this new assertion method. With that I will probably also deprecate the ShouldHaveMadeRequestsTo methods.

Once I can support C# 11, which will include unions, I will also provide and overload of ShouldHaveMadeRequests with the Request type exposed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeThis issue or pull request introduces a breaking change

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions