Class TestHttpRequestBuilder

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

Fluently builds an isolated-worker HTTP trigger request.

public sealed class TestHttpRequestBuilder
Inheritance
TestHttpRequestBuilder
Inherited Members

Methods

Build()

Creates the HTTP request data instance.

public HttpRequestData Build()

Returns

HttpRequestData

A new request with a caller-owned read-only body stream, also captured as the context's request HTTP-trigger input. Headers and identities reflect the builder's collections; avoid further builder mutation while using the request.

WithHeader(string, string)

Adds a request header.

public TestHttpRequestBuilder WithHeader(string name, string value)

Parameters

name string

The non-empty header name.

value string

The non-null header value; empty text is accepted.

Returns

TestHttpRequestBuilder

This builder, for chaining. Repeated calls can add multiple values.

WithIdentity(ClaimsIdentity)

Adds an authenticated or unauthenticated claims identity.

public TestHttpRequestBuilder WithIdentity(ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The non-null identity reference to retain. It is not cloned, so later identity mutations are visible.

Returns

TestHttpRequestBuilder

This builder, for chaining. Identities retain insertion order.

WithJsonBody<T>(T, JsonSerializerOptions?)

Serializes a value as a JSON request body.

public TestHttpRequestBuilder WithJsonBody<T>(T value, JsonSerializerOptions? options = null)

Parameters

value T

The value serialized immediately; null is emitted when T permits it.

options JsonSerializerOptions

JSON options to use, or null for new web defaults. The content type is set to application/json; charset=utf-8.

Returns

TestHttpRequestBuilder

This builder, for chaining, replacing the previous body.

Type Parameters

T

The value type to serialize.

WithMethod(HttpMethod)

Sets the HTTP method.

public TestHttpRequestBuilder WithMethod(HttpMethod method)

Parameters

method HttpMethod

The non-null HTTP method whose method text is copied.

Returns

TestHttpRequestBuilder

This builder, for chaining.

WithMethod(string)

Sets the HTTP method.

public TestHttpRequestBuilder WithMethod(string method)

Parameters

method string

The non-empty method text retained without normalization. The default is GET.

Returns

TestHttpRequestBuilder

This builder, for chaining.

WithTextBody(string, string)

Sets a UTF-8 text body and its content type.

public TestHttpRequestBuilder WithTextBody(string value, string contentType = "text/plain; charset=utf-8")

Parameters

value string

The non-null text encoded immediately as UTF-8; empty text is accepted.

contentType string

A non-empty syntactically valid media type. The default is text/plain; charset=utf-8. Any existing content-type header is replaced.

Returns

TestHttpRequestBuilder

This builder, for chaining, replacing the previous body.

WithUrl(string)

Sets an absolute URL, or a URL relative to http://localhost/.

public TestHttpRequestBuilder WithUrl(string url)

Parameters

url string

The non-empty absolute or relative URL text.

Returns

TestHttpRequestBuilder

This builder, for chaining, with relative input resolved against http://localhost/.

WithUrl(Uri)

Sets the request URL.

public TestHttpRequestBuilder WithUrl(Uri url)

Parameters

url Uri

The non-null absolute or relative URI.

Returns

TestHttpRequestBuilder

This builder, for chaining, with relative input resolved against http://localhost/.