Class ProtoHttpClientInitializer

Namespace
ProtoTest.Http
Assembly
ProtoTest.Http.dll

Initializes a named HTTP client from an explicit URL, or from the application the target belongs to: the application's base address, optionally combined with one of its named endpoint paths.

public sealed class ProtoHttpClientInitializer : IProtoClientInitializer<HttpClient>, IProtoClientInitializer
Inheritance
ProtoHttpClientInitializer
Implements
Inherited Members
Extension Methods

Constructors

ProtoHttpClientInitializer(string, string, string?, bool, string?, string?)

Initializes a named HTTP client from an explicit URL, or from the application the target belongs to: the application's base address, optionally combined with one of its named endpoint paths.

public ProtoHttpClientInitializer(string protocolName, string name, string? explicitBaseUrl = null, bool allowMissingBaseUrl = false, string? application = null, string? endpoint = null)

Parameters

protocolName string
name string
explicitBaseUrl string
allowMissingBaseUrl bool
application string
endpoint string

Properties

Name

Gets the registration name for this client (e.g., "Default", "OrderService"). Initializers with the same Protocol, client type and name form an ordered provider chain.

public string Name { get; }

Property Value

string

Protocol

Gets the protocol this initializer serves (for example "Rest"), or null for a host-level client. Protocols keep their own provider chains, and a provider registers its client under Protocol:Name (see ScopedName(string?, string)), so two protocols can own the same client name without shadowing each other.

public string Protocol { get; }

Property Value

string

Methods

GetFactoryName(string, string)

public static string GetFactoryName(string protocolName, string clientName)

Parameters

protocolName string
clientName string

Returns

string

TryInitializeAsync(ProtoExecutionContext)

Attempts to build and register the client into the specified test execution context. Returns false without changing the context when this initializer cannot provide the client for the current configuration.

The test lifecycle carries the caller's cancellation token, or the runner's own where its adapter has one; an initializer reads it from CancellationToken and passes it to its own I/O. MSTest's extension point exposes no token, so that adapter starts with None; a run-scoped hook is the cancellable extension point.

public Task<bool> TryInitializeAsync(ProtoExecutionContext context)

Parameters

context ProtoExecutionContext

Returns

Task<bool>