Gabbium.HttpClientTestExtensions
1.0.1
dotnet add package Gabbium.HttpClientTestExtensions --version 1.0.1
NuGet\Install-Package Gabbium.HttpClientTestExtensions -Version 1.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="Gabbium.HttpClientTestExtensions" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gabbium.HttpClientTestExtensions" Version="1.0.1" />
<PackageReference Include="Gabbium.HttpClientTestExtensions" />
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 Gabbium.HttpClientTestExtensions --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Gabbium.HttpClientTestExtensions, 1.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 Gabbium.HttpClientTestExtensions@1.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=Gabbium.HttpClientTestExtensions&version=1.0.1
#tool nuget:?package=Gabbium.HttpClientTestExtensions&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
HttpClient Test Extensions
๐ About
Gabbium.HttpClientTestExtensions provides fluent, readable assertions for HttpResponseMessage in integration and functional tests.
It focuses on clarity (response.ShouldBeOkWithBody<T>()) and common web testing scenarios, including ProblemDetails and ValidationProblemDetails.
Use it to:
- Make readable and expressive HTTP assertions in tests.
- Standardize JSON body reading and type checks across test suites.
- Assert ProblemDetails-based error responses consistently.
โจ Highlights
- โ
Fluent assertions for
HttpResponseMessage(e.g.,ShouldBeOkWithBody<T>(),ShouldBeNoContent()). - ๐ฆ Built-in JSON handling using
System.Text.JsonwithJsonSerializerDefaults.Web. - ๐งฐ First-class support for
ProblemDetailsandValidationProblemDetails. - ๐งช Designed for ASP.NET Core integration/functional tests with
HttpClient. - ๐ชถ Lightweight and dependency-minimal.
๐ฆ Installation
dotnet add package Gabbium.HttpClientTestExtensions
๐ Quick Start
using System.Net;
using System.Net.Http.Json;
using HttpClientTestExtensions; // your library namespace
public sealed record UserDto(Guid Id, string Name);
var response = await client.PostAsJsonAsync("/api/users", new { Name = "Alice" });
// Created with body + checks Location header against the created resource
var created = await response.ShouldBeCreatedWithBodyAndLocation<UserDto>(x => $"/api/users/{x.Id}");
// Later on...
var get = await client.GetAsync($"/api/users/{created.Id}");
var body = await get.ShouldBeOkWithBody<UserDto>();
body.Name.ShouldBe("Alice");
๐ Common Scenarios
response.ShouldBeOk();
await response.ShouldBeOkWithBody<MyDto>();
response.ShouldBeCreated();
await response.ShouldBeCreatedWithBody<MyDto>();
await response.ShouldBeCreatedWithBodyAndLocation<MyDto>(x => $"/api/items/{x.Id}");
response.ShouldBeNoContent();
await response.ShouldBeBadRequestWithValidation();
await response.ShouldBeBadRequestWithProblem();
response.ShouldBeUnauthorized();
response.ShouldBeForbidden();
await response.ShouldBeNotFoundWithProblem();
await response.ShouldBeConflictWithProblem();
await response.ShouldBeUnprocessableEntityWithProblem();
๐ก Notes
- Uses
Constants.DefaultJsonOptions(configured withJsonSerializerDefaults.WebandJsonStringEnumConverter). - Works seamlessly with
ShouldlyorFluentAssertionsfor body-level comparisons. - Perfect for
xUnitorNUnitintegration test suites.
๐ชช License
This project is licensed under the MIT License โ see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net9.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Shouldly (>= 4.3.0)
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 |
|---|---|---|
| 1.0.1 | 161 | 10/11/2025 |