-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Make HttpCall Mockable #304
Comments
It has a public constructor. 3 actually. :) |
Sorry, my mistake. I should have said |
Ah, right you are. I agree, having a public constructor would make it more easily testable. I'm not sure off hand whether making one or both of the existing ones public would be most appropriate or whether creating a new one would be better (feel free to give me your preference), but I'll look into it for the next maintenance release. |
This is implemented and released in Flurl.Http 2.3.1. |
Since there is no public constructor and HttpCall has no virtual implementation (no interface), it is not readily mocked, at least not without having to buy a framework to do so at an IL level.
I can guess that there will be a response like "catch the exception where the call to Flurl is made and and throw your own exception". However, we then get into a non-DRY scenario or limiting access to the otherwise useful information in the FlurlHttpCall.
What would be the argument against exposing FlurthHttpCall's constructor and enough of the setup/setter functionality such that we can mock for unit tests accordingly?
The text was updated successfully, but these errors were encountered: