Git Product home page Git Product logo

Comments (4)

awalsh128 avatar awalsh128 commented on August 13, 2024

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.

AmbroiseCouissin avatar AmbroiseCouissin commented on August 13, 2024

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.

awalsh128 avatar awalsh128 commented on August 13, 2024

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.

AmbroiseCouissin avatar AmbroiseCouissin commented on August 13, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.