-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for verifying a request was made #35
Comments
This functionality is somewhat supported using Could you talk through the details of your scenario so I can understand it better? |
I want to be able to test that the url requested was expected for the scenario, regardless of the response. e.g. (pseudo code) void MethodToTest(){
var url = someMethodThatGeneratesAUrl();
if(someCondition){
httpClient.GetAsync(url);
}
......
} Then in my test, all I want to do is check that GetAsync was called exactly one time with the correct url given the condition. void TestMethod(){
MethodToTest();
mockedClient.VerifyUrl(theUrlExpected, Times.Once); // or Times.Never if I expect it not to get called
} Does that explain it a little better? Happy to help out with a PR, am curious if this is functionality you would consider adding. |
This was just released in 3.2.0 |
Hi @dpix, Just to follow up, the implementation I ended up going for was to track the number of times a specific The reason I went in this direction is that using a URL would have raised questions around matching with/without querystring (or the order of keys), which would lead back to The reason it matches against an existing instance of Hope that make sense. I've also added an example to the README:
PS. I do generally promote PRs and discussion around features, but I haven't had a lot of time to work on the library so when I had the chance I ran through all of the feature I thought I could do at one time. |
Looks great @richardszalay! I'll make sure to update and check it out next I'm updating the tests I was working on |
Firstly, this is a great library 👍
It would be great to have a verify method somewhat like that in Moq. So that I can verify that my HttpClient made was called at all with the correct URL, regardless of response. Could also include functionality for expecting a particular response.
e.g.
Is this something you would consider adding to the API?
The text was updated successfully, but these errors were encountered: