Class ProtoCapabilityExtensions

Namespace
ProtoTest.Core
Assembly
ProtoTest.Core.dll

Registers capability descriptors from the host builder or from an application builder.

public static class ProtoCapabilityExtensions
Inheritance
ProtoCapabilityExtensions
Inherited Members

Methods

AddCapability(IServiceCollection, ProtoCapabilityDescriptor)

Records a capability or adapter into a service collection. This is the service-collection form of AddCapability(IProtoHostBuilder, ProtoCapabilityDescriptor) for an integration whose registration helper serves both the host and application builders and therefore only has the collection at hand; the builder overloads are the usual entry point. Registering here and on a builder is the same declaration, so a helper can switch between the two forms freely.

public static void AddCapability(IServiceCollection services, ProtoCapabilityDescriptor capability)

Parameters

services IServiceCollection
capability ProtoCapabilityDescriptor

AddCapability(IProtoApplicationBuilder, ProtoCapabilityDescriptor)

Records a capability or adapter one application is composed of.

public static IProtoApplicationBuilder AddCapability(this IProtoApplicationBuilder builder, ProtoCapabilityDescriptor capability)

Parameters

builder IProtoApplicationBuilder
capability ProtoCapabilityDescriptor

Returns

IProtoApplicationBuilder

AddCapability(IProtoHostBuilder, ProtoCapabilityDescriptor)

Records a capability or adapter the host is composed of.

public static IProtoHostBuilder AddCapability(this IProtoHostBuilder builder, ProtoCapabilityDescriptor capability)

Parameters

builder IProtoHostBuilder
capability ProtoCapabilityDescriptor

Returns

IProtoHostBuilder

AddCapabilityReason(IProtoHostBuilder, string, string, string?)

Declares the reason the suite's capability gates of kind report when they skip, so one sentence covers every gated test instead of repeating on each attribute. Omit name for the kind as a whole, or set it to narrow the reason to one capability name (or the instance a capability describes, such as a named server). A gate's own Reason still overrides it, and a gate whose kind has no declared reason falls back to the attribute's default message.

public static IProtoHostBuilder AddCapabilityReason(this IProtoHostBuilder builder, string kind, string reason, string? name = null)

Parameters

builder IProtoHostBuilder
kind string
reason string
name string

Returns

IProtoHostBuilder

Remarks

The reason is resolved when the adapter evaluates the skip, through FindCapabilityReason(string, string?). Declare the reason on the host builder before Build(), like every other composition entry.

AddCapabilityUnlessConfigured(IProtoApplicationBuilder, ProtoCapabilityDescriptor, params string[])

Records a conditional capability one application is composed of.

public static IProtoApplicationBuilder AddCapabilityUnlessConfigured(this IProtoApplicationBuilder builder, ProtoCapabilityDescriptor capability, params string[] settings)

Parameters

builder IProtoApplicationBuilder
capability ProtoCapabilityDescriptor
settings string[]

Returns

IProtoApplicationBuilder

AddCapabilityUnlessConfigured(IProtoHostBuilder, ProtoCapabilityDescriptor, params string[])

Records a capability the host is composed of unless every key in settings already has a configured value. The declaration is then dropped before the run starts: HasCapability(string, string?) answers false and [RequiresCapability] skips, exactly as if the integration behind it were never registered, instead of advertising something the environment provides elsewhere.

public static IProtoHostBuilder AddCapabilityUnlessConfigured(this IProtoHostBuilder builder, ProtoCapabilityDescriptor capability, params string[] settings)

Parameters

builder IProtoHostBuilder
capability ProtoCapabilityDescriptor
settings string[]

Returns

IProtoHostBuilder

Remarks

This is the capability half of the address-provider rule (AddInfrastructure(IProtoHostBuilder, IProtoInfrastructure, params string[])). The decision is made when the host is built, so it reads configuration, not addresses infrastructure publishes later.

AddCapabilityWhenInProcess(IProtoHostBuilder, string, ProtoCapabilityDescriptor, params string[])

Declares a capability while the named application is served in-process: the application's provider chain winner declares the server capability. An adapter that exists only behind the in-process test host (the in-process WebSocket device transport) declares itself this way, so a configured, loopback or AppHost-served application drops it and the gate skips.

public static IProtoHostBuilder AddCapabilityWhenInProcess(this IProtoHostBuilder builder, string applicationName, ProtoCapabilityDescriptor capability, params string[] configuredKeys)

Parameters

builder IProtoHostBuilder
applicationName string
capability ProtoCapabilityDescriptor
configuredKeys string[]

Returns

IProtoHostBuilder

Remarks

A host whose application declares no chain keeps the configured-keys rule over configuredKeys, so the capability drops when every key is configured and the environment provides the address elsewhere.

AddCapabilityWhenProvided(IProtoApplicationBuilder, ProtoCapabilityDescriptor, params string[])

Records a provided-capability declaration one application is composed of.

public static IProtoApplicationBuilder AddCapabilityWhenProvided(this IProtoApplicationBuilder builder, ProtoCapabilityDescriptor capability, params string[] keys)

Parameters

builder IProtoApplicationBuilder
capability ProtoCapabilityDescriptor
keys string[]

Returns

IProtoApplicationBuilder

AddCapabilityWhenProvided(IProtoHostBuilder, ProtoCapabilityDescriptor, params string[])

Records a capability the host is composed of only while at least one of keys can provide it. The declaration is dropped when none of the keys is provided - no configured value and no registered infrastructure piece declares it - so HasCapability(string, string?) answers false and [RequiresCapability] skips instead of advertising an integration whose address cannot exist.

public static IProtoHostBuilder AddCapabilityWhenProvided(this IProtoHostBuilder builder, ProtoCapabilityDescriptor capability, params string[] keys)

Parameters

builder IProtoHostBuilder
capability ProtoCapabilityDescriptor
keys string[]

Returns

IProtoHostBuilder

Remarks

This is the address half of the address-provider rule: an integration whose address is missing stays inert and its capability is absent, so tests skip rather than fail at setup or first use. The decision is made when the host is built; a key a registered infrastructure piece declares counts as provided even before the piece starts, including a piece the build skips because configuration already fills its keys.