Comments (4)
Hi Ambroise,
We can provide an interface in a future release for you to mock the client. The request and response objects will probably need to be wrappers around the System.[Net.Http,Web] equivalents since they didn't really design them for mocking. I will update the issue when we have something to release.
from dotnetsdk.
An interface will do.
Actually the HttpMessageHandler in the HttpClient is mocked easily.
Also, the reuse of HttpClient multiplies performance and is something that should be done perfectly. Or you can give the option of injecting it so that we can use it like we want for mocking or for generating it from the IoC container.
You can have a good example from salesforce SDK for .net.
Thanks
from dotnetsdk.
Version 1.0.5.0 has been released which allows you to mock the web services via its interfaces or change the HttpMessageHandler behavior.
Thanks for your feedback. We currently observe HttpClient best practices in previous versions. Most importantly, the use of a shared object among many callers.
from dotnetsdk.
Thanks a lot!
For HttpClient, I believe that the best way is to give the option for us to inject the HttpClient. And to give a default if not injected. You can just put the HttpClient as an optional attribute in the constructors. Or you can overload your constructors with an HttpClient attribute.
Sometimes people want to use a separate HttpClient per uri, or per request, or share an HttpClient among all the calls.
Giving the option is easy to implement and very cool to have so that we can command the generation and lifecycle of the HttpClient from the IoC.
Thanks
from dotnetsdk.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotnetsdk.