Class ControllerResponseSnapshot
- Namespace
- XBullet.EasyTesting.Snapshots
- Assembly
- XBullet.EasyTesting.Snapshots.Core.dll
A stable representation of an HTTP controller response for snapshot assertions.
public sealed record ControllerResponseSnapshot : IEquatable<ControllerResponseSnapshot>
- Inheritance
-
ControllerResponseSnapshot
- Implements
- Inherited Members
Constructors
ControllerResponseSnapshot(ControllerRequestSnapshot?, int, string?, IReadOnlyDictionary<string, string[]>, object?)
A stable representation of an HTTP controller response for snapshot assertions.
public ControllerResponseSnapshot(ControllerRequestSnapshot? Request, int StatusCode, string? ReasonPhrase, IReadOnlyDictionary<string, string[]> Headers, object? Body)
Parameters
RequestControllerRequestSnapshotCaptured request context, or null when request capture is disabled or no request is associated with the response.
StatusCodeintNumeric HTTP status code.
ReasonPhrasestringHTTP reason phrase, or null when none is supplied.
HeadersIReadOnlyDictionary<string, string[]>Captured headers, or an empty case-insensitive dictionary when header capture is disabled.
BodyobjectCaptured JSON, text, or base64 binary body, or null when body capture is disabled or the body is empty.
Properties
Body
Captured JSON, text, or base64 binary body, or null when body capture is disabled or the body is empty.
public object? Body { get; init; }
Property Value
Headers
Captured headers, or an empty case-insensitive dictionary when header capture is disabled.
public IReadOnlyDictionary<string, string[]> Headers { get; init; }
Property Value
ReasonPhrase
HTTP reason phrase, or null when none is supplied.
public string? ReasonPhrase { get; init; }
Property Value
Request
Captured request context, or null when request capture is disabled or no request is associated with the response.
public ControllerRequestSnapshot? Request { get; init; }
Property Value
StatusCode
Numeric HTTP status code.
public int StatusCode { get; init; }
Property Value
Methods
FromResponseAsync(HttpResponseMessage, ControllerSnapshotOptions?, CancellationToken)
Creates a deterministic snapshot model from an HTTP response.
public static Task<ControllerResponseSnapshot> FromResponseAsync(HttpResponseMessage response, ControllerSnapshotOptions? options = null, CancellationToken cancellationToken = default)
Parameters
responseHttpResponseMessageThe caller-owned, non-null response to capture. It and its request and content are read but not disposed.
optionsControllerSnapshotOptionsOptional capture and redaction options. null uses the effective global or default controller options.
cancellationTokenCancellationTokenToken that cancels response-content reading. The default token does not cancel the operation.
Returns
- Task<ControllerResponseSnapshot>
A task whose result is a new deterministic controller-response snapshot with configured redaction applied.