Class TestcontainerExtensions

Namespace
XBullet.EasyTesting.Testcontainers
Assembly
XBullet.EasyTesting.Testcontainers.dll

Registers arbitrary Testcontainers containers with EasyTesting scenarios.

public static class TestcontainerExtensions
Inheritance
TestcontainerExtensions
Inherited Members

Methods

GetTestcontainer<TEntryPoint, TContainer>(TestScenarioScope<TEntryPoint>, string)

Gets the native container registered under a scenario resource name.

public static TContainer GetTestcontainer<TEntryPoint, TContainer>(this TestScenarioScope<TEntryPoint> scope, string resourceName) where TEntryPoint : class where TContainer : class, IContainer

Parameters

scope TestScenarioScope<TEntryPoint>

The non-null, active scenario scope containing the resource.

resourceName string

The non-empty registered resource name. Matching is case-insensitive.

Returns

TContainer

The started, scenario-owned native container. The caller may use it while the scope is active but must not dispose or retain it beyond scope disposal.

Type Parameters

TEntryPoint

The application entry-point type hosted by the scenario scope.

TContainer

The expected concrete container type.

UseTestcontainer<TContainer>(TestScenarioScopeBuilder, string, Func<TestScenarioContext, TContainer>)

Adds a container to one scenario scope.

public static TestScenarioScopeBuilder UseTestcontainer<TContainer>(this TestScenarioScopeBuilder builder, string resourceName, Func<TestScenarioContext, TContainer> createContainer) where TContainer : class, IContainer

Parameters

builder TestScenarioScopeBuilder

The non-null scenario-scope builder to configure.

resourceName string

The non-empty, case-insensitively unique scenario resource name used for diagnostics and lookup.

createContainer Func<TestScenarioContext, TContainer>

A non-null factory invoked once with the scenario context. It must return a non-null, unstarted container whose ownership transfers to the scenario.

Returns

TestScenarioScopeBuilder

The same scope builder, for chaining. The container uses no published configuration or service callback and retains at most 20,000 characters from each diagnostic output stream.

Type Parameters

TContainer

The concrete Testcontainers container type created for the scenario.

UseTestcontainer<TContainer>(TestScenarioScopeBuilder, string, Func<TestScenarioContext, TContainer>, Func<TContainer, IReadOnlyDictionary<string, string?>>?, Action<TContainer, IServiceCollection>?, int)

Adds a container to one scenario scope.

public static TestScenarioScopeBuilder UseTestcontainer<TContainer>(this TestScenarioScopeBuilder builder, string resourceName, Func<TestScenarioContext, TContainer> createContainer, Func<TContainer, IReadOnlyDictionary<string, string?>>? configurationValues, Action<TContainer, IServiceCollection>? configureServices, int maximumDiagnosticCharacters) where TContainer : class, IContainer

Parameters

builder TestScenarioScopeBuilder

The non-null scenario-scope builder to configure.

resourceName string

The non-empty, case-insensitively unique scenario resource name used for diagnostics and lookup.

createContainer Func<TestScenarioContext, TContainer>

A non-null factory invoked once with the scenario context. It must return a non-null, unstarted container whose ownership transfers to the scenario.

configurationValues Func<TContainer, IReadOnlyDictionary<string, string>>

An optional callback invoked after readiness to obtain application configuration. It must return a non-null dictionary with non-empty keys; null values are accepted. Published values are excluded from diagnostics. The callback must not dispose the container.

configureServices Action<TContainer, IServiceCollection>

An optional callback invoked after readiness and singleton registration. It may update the service collection in place but must not retain it or dispose the scenario-owned container.

maximumDiagnosticCharacters int

The non-negative maximum number of trailing characters retained from each of standard output and standard error. Zero retains empty log strings.

Returns

TestScenarioScopeBuilder

The same scope builder, for chaining.

Type Parameters

TContainer

The concrete Testcontainers container type created for the scenario.

UseTestcontainer<TEntryPoint, TContainer>(EasyTestHostBuilder<TEntryPoint>, string, Func<TestScenarioContext, TContainer>)

Adds a container that is created for every scenario.

public static EasyTestHostBuilder<TEntryPoint> UseTestcontainer<TEntryPoint, TContainer>(this EasyTestHostBuilder<TEntryPoint> builder, string resourceName, Func<TestScenarioContext, TContainer> createContainer) where TEntryPoint : class where TContainer : class, IContainer

Parameters

builder EasyTestHostBuilder<TEntryPoint>

The non-null host builder to configure.

resourceName string

The non-empty, case-insensitively unique scenario resource name used for diagnostics and lookup.

createContainer Func<TestScenarioContext, TContainer>

A non-null factory invoked once per scenario with its context. It must return a non-null, unstarted container whose ownership transfers to the scenario.

Returns

EasyTestHostBuilder<TEntryPoint>

The same host builder, for chaining. Each container uses no published configuration or service callback and retains at most 20,000 characters from each diagnostic output stream.

Type Parameters

TEntryPoint

The application entry-point type configured by the host builder.

TContainer

The concrete Testcontainers container type created for each scenario.

UseTestcontainer<TEntryPoint, TContainer>(EasyTestHostBuilder<TEntryPoint>, string, Func<TestScenarioContext, TContainer>, Func<TContainer, IReadOnlyDictionary<string, string?>>?, Action<TContainer, IServiceCollection>?, int)

Adds a container that is created for every scenario.

public static EasyTestHostBuilder<TEntryPoint> UseTestcontainer<TEntryPoint, TContainer>(this EasyTestHostBuilder<TEntryPoint> builder, string resourceName, Func<TestScenarioContext, TContainer> createContainer, Func<TContainer, IReadOnlyDictionary<string, string?>>? configurationValues, Action<TContainer, IServiceCollection>? configureServices, int maximumDiagnosticCharacters) where TEntryPoint : class where TContainer : class, IContainer

Parameters

builder EasyTestHostBuilder<TEntryPoint>

The non-null host builder to configure.

resourceName string

The non-empty, case-insensitively unique scenario resource name used for diagnostics and lookup.

createContainer Func<TestScenarioContext, TContainer>

A non-null factory invoked once per scenario with its context. It must return a non-null, unstarted container whose ownership transfers to the scenario.

configurationValues Func<TContainer, IReadOnlyDictionary<string, string>>

An optional callback invoked after the container is ready to obtain application configuration. It must return a non-null dictionary with non-empty keys; null values are accepted. Published values are excluded from scenario diagnostics. The callback must not dispose the container.

configureServices Action<TContainer, IServiceCollection>

An optional callback invoked after readiness and after the container is registered as a singleton. It may update the scenario service collection in place but must not retain the collection or dispose the scenario-owned container.

maximumDiagnosticCharacters int

The non-negative maximum number of trailing characters retained from each of standard output and standard error. Zero retains empty log strings.

Returns

EasyTestHostBuilder<TEntryPoint>

The same host builder, for chaining.

Type Parameters

TEntryPoint

The application entry-point type configured by the host builder.

TContainer

The concrete Testcontainers container type created for each scenario.