Class ProtoHttpProtocolBuilder<TBuilder>

Namespace
ProtoTest.Http
Assembly
ProtoTest.Http.dll

Shared fluent surface for the HTTP-based protocol builders: named and resolver-based clients, response options and attachment capture. A protocol supplies its key, its configuration sections and the label used when a client is registered under an application.

public abstract class ProtoHttpProtocolBuilder<TBuilder> where TBuilder : ProtoHttpProtocolBuilder<TBuilder>

Type Parameters

TBuilder
Inheritance
ProtoHttpProtocolBuilder<TBuilder>
Derived
Inherited Members
Extension Methods

Constructors

ProtoHttpProtocolBuilder(IServiceCollection, string, string, string, string, IProtoApplicationBuilder?)

protected ProtoHttpProtocolBuilder(IServiceCollection services, string protocolName, string applicationClientLabel, string responsesConfigurationSectionName, string attachmentsConfigurationSectionName, IProtoApplicationBuilder? application = null)

Parameters

services IServiceCollection
protocolName string
applicationClientLabel string
responsesConfigurationSectionName string
attachmentsConfigurationSectionName string
application IProtoApplicationBuilder

Properties

Services

public IServiceCollection Services { get; }

Property Value

IServiceCollection

Methods

AddClient(string?, Func<ProtoExecutionContext, CancellationToken, ValueTask<Uri>>, Action<IHttpClientBuilder>?)

Adds a client whose absolute base address is resolved from per-test context.

public IProtoTargetBuilder AddClient(string? name, Func<ProtoExecutionContext, CancellationToken, ValueTask<Uri>> baseAddressResolver, Action<IHttpClientBuilder>? configure = null)

Parameters

name string
baseAddressResolver Func<ProtoExecutionContext, CancellationToken, ValueTask<Uri>>
configure Action<IHttpClientBuilder>

Returns

IProtoTargetBuilder

AddClient(string?, Func<ProtoExecutionContext, Uri>, Action<IHttpClientBuilder>?)

Adds a client whose absolute base address is read from per-test context.

public IProtoTargetBuilder AddClient(string? name, Func<ProtoExecutionContext, Uri> baseAddressResolver, Action<IHttpClientBuilder>? configure = null)

Parameters

name string
baseAddressResolver Func<ProtoExecutionContext, Uri>
configure Action<IHttpClientBuilder>

Returns

IProtoTargetBuilder

AddClient(string?, string?, Action<IHttpClientBuilder>?, string?)

Registers a named client. Inside AddApplication the client belongs to that application and takes its address from ProtoTest:Applications:{app}, optionally combined with a named endpoint. The name may be omitted for an application's only client.

public IProtoTargetBuilder AddClient(string? name = null, string? baseUrl = null, Action<IHttpClientBuilder>? configure = null, string? endpoint = null)

Parameters

name string
baseUrl string
configure Action<IHttpClientBuilder>
endpoint string

Returns

IProtoTargetBuilder

CaptureAttachments(Action<ProtoHttpAttachmentOptions>?)

Enables automatic request, response, and expected-shape test attachments.

public TBuilder CaptureAttachments(Action<ProtoHttpAttachmentOptions>? configure = null)

Parameters

configure Action<ProtoHttpAttachmentOptions>

Returns

TBuilder

ConfigureResponses(Action<ProtoHttpResponseOptions>)

Tunes response buffering and status diagnostics for this protocol.

public TBuilder ConfigureResponses(Action<ProtoHttpResponseOptions> configure)

Parameters

configure Action<ProtoHttpResponseOptions>

Returns

TBuilder