MockHttp is a testing layer for Microsoft's HttpClient library. It allows stubbed responses to be configured for matched HTTP requests and can be used to test your application's service layer. MockHttp defines a replacement HttpMessageHandler, the engine that drives HttpClient, that provides a fluent configuration API and provides a canned response. The caller (eg. your application's service layer) remains unaware of its presence. MockHttpMessageHandler defines both When and Expect, which can be used to define responses. They both expose the same fluent API, but each works in a slightly different way. Using When specifies a "Backend Definition". Backend Definitions can be matched against multiple times and in any order, but they won't match if there are any outstanding Request Expectations present (unless BackendDefinitionBehavior.Always is specified).

Features

  • The Fallback property handles all requests that weren't handled by the match behavior
  • MockHttp is compiled for .NET Standard 2.0, .NET Standard 1.1, .NET 4, and .NET 4.5, as well a Portable Class Library (Profile 328)
  • License under the MIT license
  • MockHttpMessageHandler defines both When and Expect, which can be used to define responses
  • MockHttp defines a replacement HttpMessageHandler
  • MockHttp is a testing layer for Microsoft's HttpClient library

Project Samples

Project Activity

See All Activity >

Categories

Frameworks

License

MIT License

Follow MockHttp for HttpClient

MockHttp for HttpClient Web Site

You Might Also Like
Find out just how much your login box can do for your customer | Auth0 Icon
Find out just how much your login box can do for your customer | Auth0

With over 53 social login options, you can fast-track the signup and login experience for users.

From improving customer experience through seamless sign-on to making MFA as easy as a click of a button – your login box must find the right balance between user convenience, privacy and security.
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of MockHttp for HttpClient!

Additional Project Details

Operating Systems

Android, Apple iPhone, Windows

Programming Language

C#

Related Categories

C# Frameworks

Registered

2022-09-19