aweXpect.Web
4.0.0-pre.3
Prefix Reserved
dotnet add package aweXpect.Web --version 4.0.0-pre.3
NuGet\Install-Package aweXpect.Web -Version 4.0.0-pre.3
<PackageReference Include="aweXpect.Web" Version="4.0.0-pre.3" />
<PackageVersion Include="aweXpect.Web" Version="4.0.0-pre.3" />
<PackageReference Include="aweXpect.Web" />
paket add aweXpect.Web --version 4.0.0-pre.3
#r "nuget: aweXpect.Web, 4.0.0-pre.3"
#:package aweXpect.Web@4.0.0-pre.3
#addin nuget:?package=aweXpect.Web&version=4.0.0-pre.3&prerelease
#tool nuget:?package=aweXpect.Web&version=4.0.0-pre.3&prerelease
aweXpect.Web
aweXpect.Web contains expectations for HttpRequestMessage,
HttpResponseMessage, Uri and IPAddress, e.g. to verify the responses of an HttpClient.
Installation
dotnet add package aweXpect.Web
The package brings Expect.That with it, but not the expectations for strings, numbers or collections, so reference
aweXpect as well. The expectations live in the namespace aweXpect, so
using aweXpect; is all you need; only the customization lives in aweXpect.Web.
At a glance
HttpResponseMessage response = await httpClient.GetAsync("https://music.example.com/tracks/1");
// verify the status code, either the exact value or its category
await Expect.That(response).HasStatusCode().Success();
// verify the media type and the headers of the response
await Expect.That(response).HasContentType("application/json");
await Expect.That(response).HasHeader("Cache-Control").WithValue("must-revalidate, max-age=0, private");
// verify the content of the response
await Expect.That(response).HasContent("*Let It Be*").AsWildcard();
A failing expectation on a request or response includes the formatted HTTP request and response. If the test server
returned the track, HasStatusCode(HttpStatusCode.NotFound) would fail with:
Expected that response
has status code equal to 404 NotFound,
but it had status code 200 OK
HTTP-Request:
GET http://localhost/tracks/1 HTTP/1.1
HTTP-Response:
200 OK HTTP/1.1
x-vendor: VENDOR
Content-Type: application/json; charset=utf-8
Content-Length: 51
{
"id": 1,
"title": "Let It Be",
"artist": "The Beatles"
}
Overview
Expectations for HttpRequestMessage:
| Expectation | Negated | Summary |
|---|---|---|
HasMethod |
DoesNotHaveMethod |
has the expected HTTP method |
HasRequestUri |
DoesNotHaveRequestUri |
has the expected request URI |
HasHeader |
DoesNotHaveHeader |
has a header, optionally with a value |
HasContentType |
DoesNotHaveContentType |
has the expected media type |
HasContent |
DoesNotHaveContent |
has the expected string content |
Expectations for HttpResponseMessage:
| Expectation | Negated | Summary |
|---|---|---|
HasStatusCode |
DoesNotHaveStatusCode |
has the expected status code or status category |
HasHeader |
DoesNotHaveHeader |
has a header, optionally with a value |
HasContentType |
DoesNotHaveContentType |
has the expected media type |
HasContent |
DoesNotHaveContent |
has the expected string content |
HasProblemDetailsContent |
use DoesNotHaveContentType |
has a ProblemDetails content |
HasRequestMessage |
the request message meets nested expectations |
Expectations for Uri:
| Expectation | Negated | Summary |
|---|---|---|
IsAbsolute |
IsNotAbsolute |
an absolute URI |
IsFile |
IsNotFile |
a file URI |
IsLoopback |
IsNotLoopback |
references the local host |
IsUnc |
IsNotUnc |
a UNC path |
HasDefaultPort |
DoesNotHaveDefaultPort |
uses the default port of its scheme |
HasPort |
use HasPort().NotEqualTo(…) |
has the expected port |
HasScheme |
use HasScheme().NotEqualTo(…) |
has the expected scheme |
HasHost |
use HasHost().NotEqualTo(…) |
has the expected host |
HasPath |
use HasPath().NotEqualTo(…) |
has the expected path |
HasFragment |
use HasFragment().NotEqualTo(…) |
has the expected fragment |
IsBaseOf |
IsNotBaseOf |
a base URI of the expected URI |
HasQueryParameter |
DoesNotHaveQueryParameter |
has a query parameter, optionally with a value |
Expectations for IPAddress:
| Expectation | Negated | Summary |
|---|---|---|
IsIPv4 |
IsNotIPv4 |
an IPv4 address |
IsIPv6 |
IsNotIPv6 |
an IPv6 address |
IsLoopback |
IsNotLoopback |
a loopback address |
IsInSubnet |
IsNotInSubnet |
in the expected subnet |
IsEqualTo |
IsNotEqualTo |
equal to the expected address, optionally ignoring mapping |
Customization
Set a value under Customize.aweXpect.Web() for the current
async flow, or under
Customize.aweXpect.Global.Web() for
all tests.
| Value | Default | Summary |
|---|---|---|
ContentProcessors |
JsonContentProcessor, StringContentProcessor, BinaryContentProcessor |
format the content of requests and responses in failure messages |
Documentation
The full documentation is available at docs.testably.org:
- HTTP requests and responses: method, request URI, headers, content type and content of an
HttpRequestMessage, and status code, headers, content type, content, problem details and the request message of anHttpResponseMessage - URIs: kind, port, scheme, host, path, fragment, base URI and query parameters of a
Uri - IP addresses: IPv4, IPv6, loopback, subnet membership and equality of an
IPAddress - Customization: formatting the request and response content in failure messages
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- aweXpect.Core (>= 4.0.0-pre.3)
- System.Text.Json (>= 10.0.14)
-
net10.0
- aweXpect.Core (>= 4.0.0-pre.3)
-
net8.0
- aweXpect.Core (>= 4.0.0-pre.3)
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 |
|---|---|---|
| 4.0.0-pre.3 | 46 | 10/29/2026 |
| 4.0.0-pre.2 | 50 | 10/27/2026 |
| 4.0.0-pre.1 | 54 | 10/22/2026 |
| 2.1.0 | 107 | 10/16/2026 |
| 2.0.0 | 93 | 10/10/2026 |
| 2.0.0-pre.2 | 59 | 10/8/2026 |
| 2.0.0-pre.1 | 68 | 9/28/2026 |
| 1.8.0 | 127 | 9/5/2026 |
| 1.7.0 | 136 | 5/10/2026 |
| 1.6.0 | 244 | 10/19/2025 |
| 1.4.0 | 239 | 9/10/2025 |
| 1.3.0 | 254 | 6/30/2025 |
| 1.2.0 | 171 | 5/10/2025 |
| 1.1.0 | 266 | 4/1/2025 |
| 1.0.0 | 240 | 3/19/2025 |
| 1.0.0-pre.1 | 130 | 3/15/2025 |
| 0.6.0 | 197 | 3/1/2025 |
| 0.5.0 | 201 | 2/28/2025 |
| 0.4.0 | 202 | 2/23/2025 |
| 0.3.0 | 226 | 2/21/2025 |