Class ProtoGrpcClientInitializer

Namespace
ProtoTest.Grpc.Clients
Assembly
ProtoTest.Grpc.dll

Initializes a named gRPC client from an explicit address, or from the application it belongs to: the application's Grpc:Address, its base address, or its in-process transport. The channel is created when the client is first used, so an application whose test server starts later still works.

public sealed class ProtoGrpcClientInitializer : IProtoClientInitializer<ProtoGrpcClient>, IProtoClientInitializer
Inheritance
ProtoGrpcClientInitializer
Implements
Inherited Members
Extension Methods

Constructors

ProtoGrpcClientInitializer(string, string, GrpcClientOptions, string?, bool, string?, Func<ProtoExecutionContext, CancellationToken, ValueTask<Uri>>?)

Initializes a named gRPC client from an explicit address, or from the application it belongs to: the application's Grpc:Address, its base address, or its in-process transport. The channel is created when the client is first used, so an application whose test server starts later still works.

public ProtoGrpcClientInitializer(string protocolName, string name, GrpcClientOptions options, string? explicitAddress = null, bool allowMissingAddress = false, string? application = null, Func<ProtoExecutionContext, CancellationToken, ValueTask<Uri>>? addressResolver = null)

Parameters

protocolName string
name string
options GrpcClientOptions
explicitAddress string
allowMissingAddress bool
application string
addressResolver Func<ProtoExecutionContext, CancellationToken, ValueTask<Uri>>

Properties

Name

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

public string Name { get; }

Property Value

string

Methods

TryInitializeAsync(ProtoExecutionContext, CancellationToken)

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.

public Task<bool> TryInitializeAsync(ProtoExecutionContext context, CancellationToken cancellationToken = default)

Parameters

context ProtoExecutionContext
cancellationToken CancellationToken

Returns

Task<bool>