Class PostgresDatabase

Namespace
ProtoTest.Sql.Testcontainers
Assembly
ProtoTest.Sql.Testcontainers.dll

A PostgreSQL container owned by the whole run: started once for the suite and released when the host is disposed, after the run has stopped and the reports are written. Register it with AddInfrastructure and hand its connection string to the application and to the tests so both work against the same database.

public sealed class PostgresDatabase : ProtoContainerResource<PostgreSqlContainer>, IProtoConnectionInfrastructure, IProtoConfiguredInfrastructure, IProtoInfrastructure, IProtoResource, IProtoStartupEvidence, IAsyncDisposable
Inheritance
ProtoContainerResource<PostgreSqlContainer>
PostgresDatabase
Implements
Inherited Members
Extension Methods

Properties

Description

Gets a single line describing the resource for the trace, report and viewer.

public override string Description { get; }

Property Value

string

Id

Gets the stable identity of the resource, for example customer:42.

public override string Id { get; }

Property Value

string

Kind

Gets the resource kind, for example database or entity.

public override string Kind { get; }

Property Value

string

Methods

Container(Action<PostgreSqlBuilder>?)

Creates the resource without starting it; the host starts it with the run.

public static PostgresDatabase Container(Action<PostgreSqlBuilder>? configure = null)

Parameters

configure Action<PostgreSqlBuilder>

Returns

PostgresDatabase

Start(Action<PostgreSqlBuilder>?)

Starts a container now, or throws with the reason it could not start.

public static PostgresDatabase Start(Action<PostgreSqlBuilder>? configure = null)

Parameters

configure Action<PostgreSqlBuilder>

Returns

PostgresDatabase

TryStart(Action<PostgreSqlBuilder>?)

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<PostgresDatabase> TryStart(Action<PostgreSqlBuilder>? configure = null)

Parameters

configure Action<PostgreSqlBuilder>

Returns

ContainerStartResult<PostgresDatabase>