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

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
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