Git Product home page Git Product logo

httpclient.helpers's Introduction

HttpClient.Helpers

Stage CI NuGet
Production Build status NuGet Badge
Development Build status MyGet Badge

Code that uses System.Net.Http.HttpClient will attempt to actually call/hit that Http endpoint.

To prevent this from happening in a unit test, some simple helpers are provided in this code library.

Key Points

  • Use Dependency Injection to hijack your request (this library makes it supa dupa easy to do this)
  • Works with GET/POST/etc.
  • Can provide wildcards (i.e. I don't care about the Request endpoint or the request HTTP Method, etc)
  • Can provide multiple endpoints and see handle what is returned based on the particular request.
  • Can be used to test network errors during transmission. i.e. can test when the HttpClient throws an exception because of .. well ... ๐Ÿ’ฅ

Installation

Package Name: WorldDomination.HttpClient.Helpers
CLI: install-package WorldDomination.HttpClient.Helpers

Sample Code

There's plenty more examples about to wire up:

For all the samples, please check out the Wiki page: Helper Examples


Special Ackowledgements

A special and sincere thank you to David Fowler (@davidfowl) who explained how I should be unit testing the HttpClient class and gave me the guidence to make this library. I was soooo on the wrong path - and he guided me back on track.

Thank you David! ๐Ÿ‘Œ ๐Ÿธ ๐Ÿ‘พ


Summary

Finally, unit testing HttpClient is now awesome and simple!

Wohoo


I'm happy to accept tips
Lic: MIT

httpclient.helpers's People

Contributors

purekrome avatar abatishchev avatar

Watchers

James Cloos avatar

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.