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
requestHTTP-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
namestringThe non-empty header name.
valuestringThe 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
identityClaimsIdentityThe 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
valueTThe value serialized immediately; null is emitted when
Tpermits it.optionsJsonSerializerOptionsJSON 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
TThe value type to serialize.
WithMethod(HttpMethod)
Sets the HTTP method.
public TestHttpRequestBuilder WithMethod(HttpMethod method)
Parameters
methodHttpMethodThe 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
methodstringThe 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
valuestringThe non-null text encoded immediately as UTF-8; empty text is accepted.
contentTypestringA 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
urlstringThe 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
urlUriThe non-null absolute or relative URI.
Returns
- TestHttpRequestBuilder
This builder, for chaining, with relative input resolved against
http://localhost/.