![]() |
VOOZH | about |
dotnet add package MockH --version 1.12.3
NuGet\Install-Package MockH -Version 1.12.3
<PackageReference Include="MockH" Version="1.12.3" />
<PackageVersion Include="MockH" Version="1.12.3" />Directory.Packages.props
<PackageReference Include="MockH" />Project file
paket add MockH --version 1.12.3
#r "nuget: MockH, 1.12.3"
#:package MockH@1.12.3
#addin nuget:?package=MockH&version=1.12.3Install as a Cake Addin
#tool nuget:?package=MockH&version=1.12.3Install as a Cake Tool
👁 Build
👁 Coverage
👁 nuget Package
This library allows to mock HTTP responses for integration, component and acceptance tests of your projects written in C# / .NET 8/9/10 by hosting a webserver returning configured responses.
using MockH;
[TestMethod]
public async Task TestSomething()
{
await using var server = await MockServer.RunAsync
(
On.Get("/users/1").Return(new User(...)),
On.Get("/users/2").Respond(ResponseStatus.NoContent)
);
// access the server in your code via HTTP
using var client = new HttpClient();
await client.GetStringAsync(server.Url("/users/1"));
}
// return a specific status code
On.Get("/ifail").Respond(ResponseStatus.InternalServerError);
// redirect the client
On.Get().Redirect("https://github.com");
// execute logic and return some simple text value
On.Get().Run(() => "42");
// execute logic and return some JSON
private record MyClass(int IntValue, string StringValue);
On.Get().Run(() => new MyClass(42, "The answer"));
// execute logic asynchronously
On.Get().Run(async () => await ...);
// access query parameters (GET /increment?=1)
On.Get("/increment").Run((int i) => i + 1);
// access path parameters (GET /increment/1)
On.Get("/increment/:i").Run((int i) => i + 1);
// access request body
On.Post().Run((MyClass body) => body);
// access request body as stream
On.Post().Run((Stream body) => body.Length);
// directly access request and response
On.Get().Run((IRequest request) => request.Respond().Status(ResponseStatus.BadRequest));
// return a handler provided by the GenHTTP framework, e.g. a website
// see https://genhttp.org/documentation/content/
// can be useful if you want to test some kind of website crawler
On.Get().Run(() => Listing.From(ResourceTree.FromDirectory("/var/www")));
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.12.3 | 136 | 2/19/2026 |
| 1.12.2 | 203 | 12/23/2025 |
| 1.12.1 | 199 | 11/26/2025 |
| 1.12.0 | 316 | 11/12/2025 |
| 1.11.0 | 214 | 11/3/2025 |
| 1.10.0 | 201 | 1/31/2025 |
| 1.9.0 | 183 | 11/18/2024 |
| 1.7.0 | 183 | 6/4/2024 |
| 1.6.0 | 319 | 11/23/2023 |
| 1.5.0 | 279 | 7/3/2023 |
| 1.4.0 | 578 | 7/6/2022 |
| 1.3.0 | 468 | 12/22/2021 |
| 1.2.0 | 452 | 12/20/2021 |
| 1.1.0 | 441 | 12/3/2021 |
| 1.0.0 | 2,530 | 11/25/2021 |