Class ProtoRestBuilder

Namespace
ProtoTest.Rest
Assembly
ProtoTest.Rest.dll
public sealed class ProtoRestBuilder
Inheritance
ProtoRestBuilder
Inherited Members
Extension Methods

Fields

AttachmentsConfigurationSectionName

public const string AttachmentsConfigurationSectionName = "ProtoTest:Rest:Attachments"

Field Value

string

ProtocolName

Stable protocol key REST options are registered and resolved under.

public const string ProtocolName = "Rest"

Field Value

string

ResponsesConfigurationSectionName

public const string ResponsesConfigurationSectionName = "ProtoTest:Rest:Responses"

Field Value

string

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 REST client. Inside AddApplication the client belongs to that application and takes its base address from ProtoTest:Applications:{app}, optionally combined with the endpoint named after the client.

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

Parameters

name string
baseUrl string
configure Action<IHttpClientBuilder>
endpoint string

Returns

IProtoTargetBuilder

AddClientFrom(string, string, string?)

Uses the transport of an HTTP client registered by another integration, such as an in-process ASP.NET Core server, optionally rooted at a path.

public IProtoTargetBuilder AddClientFrom(string name, string sourceClientName, string? basePath = null)

Parameters

name string
sourceClientName string
basePath string

Returns

IProtoTargetBuilder

CaptureAttachments(Action<ProtoHttpAttachmentOptions>?)

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

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

Parameters

configure Action<ProtoHttpAttachmentOptions>

Returns

ProtoRestBuilder

ConfigureResponses(Action<ProtoHttpResponseOptions>)

public ProtoRestBuilder ConfigureResponses(Action<ProtoHttpResponseOptions> configure)

Parameters

configure Action<ProtoHttpResponseOptions>

Returns

ProtoRestBuilder