Class HttpResponseDataTestExtensions

Namespace
XBullet.EasyTesting.AzureFunctions
Assembly
XBullet.EasyTesting.AzureFunctions.dll

Reads in-memory HTTP responses produced by function tests.

public static class HttpResponseDataTestExtensions
Inheritance
HttpResponseDataTestExtensions
Inherited Members

Methods

ReadBodyAsJsonAsync<T>(HttpResponseData, JsonSerializerOptions?, CancellationToken)

Deserializes the response body as JSON.

public static Task<T?> ReadBodyAsJsonAsync<T>(this HttpResponseData response, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)

Parameters

response HttpResponseData

The non-null response whose body is read but left open.

options JsonSerializerOptions

JSON options to use, or null for new web defaults.

cancellationToken CancellationToken

A token that cancels body reading. The default does not request cancellation.

Returns

Task<T>

A task whose result is the deserialized value, or null when the JSON payload represents null for a nullable target.

Type Parameters

T

The target JSON model type.

ReadBodyAsStringAsync(HttpResponseData, CancellationToken)

Reads the response body as text without changing its final stream position.

public static Task<string> ReadBodyAsStringAsync(this HttpResponseData response, CancellationToken cancellationToken = default)

Parameters

response HttpResponseData

The non-null response whose body is read but left open.

cancellationToken CancellationToken

A token that cancels reading. The default does not request cancellation. A successful seekable read restores the original stream position.

Returns

Task<string>

A task whose result is the complete body decoded as UTF-8 with byte-order-mark detection.