Skip to content

Commit

Permalink
Added NpgsqlDataSource to Postgresql IntegrationContext
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Dec 5, 2023
1 parent 8c3efac commit 7219abe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Weasel.Postgresql.Tests/IntegrationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ namespace Weasel.Postgresql.Tests;

public abstract class IntegrationContext: IDisposable, IAsyncLifetime
{
protected readonly NpgsqlConnection theConnection = new NpgsqlConnection(ConnectionSource.ConnectionString);
protected readonly NpgsqlDataSource theDataSource = NpgsqlDataSource.Create(ConnectionSource.ConnectionString);
private NpgsqlConnection? connection;

protected NpgsqlConnection theConnection
{
get => (connection ??= theDataSource.CreateConnection());
}

protected IntegrationContext(string schemaName)
{
Expand All @@ -24,7 +30,8 @@ protected IntegrationContext(string schemaName)

public void Dispose()
{
theConnection?.Dispose();
connection?.Dispose();
theDataSource.Dispose();
}

protected async Task ResetSchema()
Expand Down

0 comments on commit 7219abe

Please sign in to comment.