MoqHttp 2.0.1

dotnet add package MoqHttp --version 2.0.1
                    
NuGet\Install-Package MoqHttp -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MoqHttp" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MoqHttp" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MoqHttp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MoqHttp --version 2.0.1
                    
#r "nuget: MoqHttp, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MoqHttp@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MoqHttp&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MoqHttp&version=2.0.1
                    
Install as a Cake Tool

MoqHttp

MoqHttp is a lightweight, fluent HTTP mocking and VCR library for .NET 10+. It allows you to easily spin up a local HTTP server to mock API responses or record real API interactions for consistent, fast, and offline-capable testing.


🚀 Quick Start (Traditional Mocking)

Mock any HTTP endpoint with a few lines of code:

using MoqHttp;

// 1. Create and start the server
using var mockServer = new HttpServer(5000);
mockServer.Run();

// 2. Configure an endpoint
mockServer.Config.Get("/api/data").Send("{\"status\": \"ok\"}", 200);

// 3. Your code makes a request to http://localhost:5000/api/data
var httpClient = new HttpClient();
var response = await httpClient.GetAsync("http://localhost:5000/api/data");
var contents = await response.Content.ReadAsStringAsync(); // "{\"status\": \"ok\"}"

📼 VCR Functionality (Record & Replay)

Eliminate network flakiness by recording real API responses once and replaying them in your tests.

Automatically records if the cassette file is missing, otherwise replays from disk.

mockServer.Config
    .Auto()
    .FromFile("fixtures/github_user.json")
    .ProxyTo("https://api.github.com");

mockServer.Run();
// First run: Captures real data from GitHub
// Subsequent runs: Instant playback from local file!

Advanced VCR Features

  • Filtering: Record only specific paths or HTTP verbs.
  • Transformation: Modify recorded responses on the fly (e.g., inject current timestamps).
  • Advanced Matching: Match by query strings, headers, or request bodies.

✨ Key Features

  • Zero Configuration: Starts in-process with minimal boilerplate.
  • Fluent API: Intuitive, chainable syntax for configuring mocks.
  • Standard-Compliant: Built on top of ASP.NET Core Kestrel.
  • No Dependencies: Pure .NET library using System.Text.Json.
  • Fast: VCR playback is 100x faster than real network calls.

📦 Installation

dotnet add package MoqHttp

For more documentation and examples, visit the GitHub Repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 202 12/25/2025
2.0.0 188 12/25/2025
1.1.0 1,092 3/25/2022 1.1.0 is deprecated because it is no longer maintained.
1.0.0 820 3/6/2022 1.0.0 is deprecated because it is no longer maintained.