Container to start a PostgreSQL Server container.
For more detailed examples, see our integration tests.
/*
* default image is postgres:11-alpine
*/
var container = new ContainerBuilder<PostgreSqlContainer>()
.ConfigureDatabase(myUsername, mySaPassword, myDatabaseName)
.Build();
using (var connection = new NpgsqlConnection(container.GetConnectionString()))
{
await connection.OpenAsync();
return await Record.ExceptionAsync(async () =>
{
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT 1";
await command.ExecuteScalarAsync();
}
});
}