Class ApplicationContainer
- Namespace
- ProtoTest.Testcontainers
- Assembly
- ProtoTest.Testcontainers.dll
An application under test running in its own container image: the host starts it as run
infrastructure, and the mapped address it serves on is published as the application's
BaseUrl, so the application's REST clients, browser sessions and the readiness probe all
resolve that one container. Register it as the target's UseContainer(container) provider with
UseConfigured() first, so a configured address serves the target instead.
public sealed class ApplicationContainer : ProtoContainerResource<IContainer>, IProtoConnectionInfrastructure, IProtoConfiguredInfrastructure, IProtoInfrastructure, IProtoResource, IProtoStartupEvidence, IAsyncDisposable
- Inheritance
-
ProtoContainerResource<IContainer>ApplicationContainer
- Implements
- Inherited Members
- Extension Methods
Remarks
The helper assumes nothing about the image beyond the port it listens on; the published address is
http://{hostname}:{mapped port}, and the default readiness check waits for that port to
accept a connection. The configure callback can add container build options (an environment,
a command, a Testcontainers wait strategy), and AddHttpReadiness(application, path) adds an
HTTP-level wait against the published address. A run that configures
ProtoTest:Applications:{application}:BaseUrl satisfies the declared key, so the configured
provider wins and the container is never started.
Properties
Application
Gets the application this container serves.
public string Application { get; }
Property Value
BaseUrlKey
Gets the key the started container fills with the mapped address.
public string BaseUrlKey { get; }
Property Value
Description
Gets a single line describing the resource for the trace, report and viewer.
public override string Description { get; }
Property Value
Id
Gets the stable identity of the resource, for example customer:42.
public override string Id { get; }
Property Value
Kind
Gets the resource kind, for example database or entity.
public override string Kind { get; }
Property Value
Methods
Container(string, string, int, Action<ContainerBuilder>?)
Creates the resource without starting it; the host starts it with the run.
public static ApplicationContainer Container(string application, string image, int port, Action<ContainerBuilder>? configure = null)
Parameters
Returns
Start(string, string, int, Action<ContainerBuilder>?)
Starts a container now, or throws with the reason it could not start.
public static ApplicationContainer Start(string application, string image, int port, Action<ContainerBuilder>? configure = null)
Parameters
Returns
TryStart(string, string, int, Action<ContainerBuilder>?)
Starts a container, reporting why it could not start instead of throwing - a machine without a container runtime should be able to fall back or skip rather than fail the run.
public static ContainerStartResult<ApplicationContainer> TryStart(string application, string image, int port, Action<ContainerBuilder>? configure = null)