XBullet.EasyTesting.Snapshots.Http
1.0.16
dotnet add package XBullet.EasyTesting.Snapshots.Http --version 1.0.16
NuGet\Install-Package XBullet.EasyTesting.Snapshots.Http -Version 1.0.16
<PackageReference Include="XBullet.EasyTesting.Snapshots.Http" Version="1.0.16" />
<PackageVersion Include="XBullet.EasyTesting.Snapshots.Http" Version="1.0.16" />
<PackageReference Include="XBullet.EasyTesting.Snapshots.Http" />
paket add XBullet.EasyTesting.Snapshots.Http --version 1.0.16
#r "nuget: XBullet.EasyTesting.Snapshots.Http, 1.0.16"
#:package XBullet.EasyTesting.Snapshots.Http@1.0.16
#addin nuget:?package=XBullet.EasyTesting.Snapshots.Http&version=1.0.16
#tool nuget:?package=XBullet.EasyTesting.Snapshots.Http&version=1.0.16
XBullet.EasyTesting.Snapshots.Http
Snapshot adapters for requests and complete exchanges captured by XBullet.EasyTesting.Http, plus
hosted scenario integration for HttpExchangeRecorder. The package references
XBullet.EasyTesting.Snapshots.Core and keeps the existing XBullet.EasyTesting.Snapshots namespace.
The package targets .NET 8, .NET 9, and .NET 10.
Install
dotnet add package XBullet.EasyTesting.Snapshots.Http
Example
using var response = await client.PostAsJsonAsync("/orders", order);
await handler.ShouldMatchExchangesSnapshot();
For a hosted fluent scenario, SnapshotScenario() attaches an HttpExchangeRecorder before the
request is sent:
using var result = await scope.SnapshotScenario(options =>
options.Request.RedactingHeader("X-Request-Secret"))
.PostJson("/api/products", request)
.ExecuteAsync(cancellationToken);
await result.Response.ShouldMatchHttpExchangeSnapshot(
configureSnapshot: settings => settings.ScrubMember("id"),
cancellationToken: cancellationToken);
Outbound request and exchange assertions likewise accept configureRequest, configureExchange,
and configureSnapshot callbacks in addition to prebuilt option and settings instances.
Exchange snapshots contain each request and its response status, stable headers, and normalized
body. Send failures and response-body read failures are captured as stable exception type/message
pairs. JSON request and response bodies are captured structurally; text remains text and binary
content is stored as base64. Response content that has not been consumed is represented as
{NotRead} rather than being read eagerly by the recorder.
Configure capture
Request and response capture can be customized independently:
var options = new StubHttpExchangeSnapshotOptions();
options.Request
.IgnoringHeaders("X-Retry-Count")
.RedactingHeader("X-Session")
.RedactingQueryParameter("tenant_secret")
.ScrubbingUrlPathGuids()
.ScrubbingQueryParameters("timestamp", "requestId");
options.Response
.IgnoringHeaders("ETag")
.RedactingHeader("Set-Cookie");
await handler.ShouldMatchExchangesSnapshot(
options,
new SnapshotSettings().ScrubMembers("timestamp", "requestId"));
JSON is the default. Complete exchanges can instead use an HTTP-style .verified.txt transcript
or deterministic .verified.yaml output:
var options = new StubHttpExchangeSnapshotOptions
{
Format = HttpExchangeSnapshotFormat.Yaml // or Http
};
await handler.ShouldMatchExchangesSnapshot(options);
Structured JSON scrubbers are applied before either alternative format is rendered.
Request-only snapshots remain available:
await handler.ShouldMatchRequestsSnapshot(
new StubHttpRequestSnapshotOptions()
.IgnoringHeaders("X-Retry-Count")
.RedactingHeader("X-Session")
.RedactingQueryParameter("tenant_secret")
.ScrubbingUrlPathGuids()
.ScrubbingQueryParameters("timestamp", "requestId"),
new SnapshotSettings()
.ScrubMembers("timestamp", "requestId"));
JSON request bodies are captured structurally with System.Text.Json. Authorization, cookies,
API keys, correlation IDs, and tracing headers are excluded by default. Common secret-bearing query
parameters are redacted by default; additional header and query values can be preserved as
{Redacted}.
Complete GUID path segments are captured as {Guid} when ScrubbingUrlPathGuids() is enabled.
Use ScrubbingUrlPath(path => ...) for other route transformations. Scrubbed query values appear as
{Scrubbed}; security-redacted query values appear as {Redacted} and take precedence.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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 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. |
-
net10.0
- XBullet.EasyTesting.Http (>= 1.0.16)
- XBullet.EasyTesting.Snapshots.Core (>= 1.0.16)
-
net8.0
- XBullet.EasyTesting.Http (>= 1.0.16)
- XBullet.EasyTesting.Snapshots.Core (>= 1.0.16)
-
net9.0
- XBullet.EasyTesting.Http (>= 1.0.16)
- XBullet.EasyTesting.Snapshots.Core (>= 1.0.16)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XBullet.EasyTesting.Snapshots.Http:
| Package | Downloads |
|---|---|
|
XBullet.EasyTesting.Snapshots
Compatibility facade for the split snapshot core and outbound HTTP adapter packages. |
GitHub repositories
This package is not used by any popular GitHub repositories.