Skip to content

Commit

Permalink
fix: Dispose connection in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Sep 28, 2024
1 parent 86bf9f8 commit 7cb2a2b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ namespace LinkDotNet.Blog.IntegrationTests;
public abstract class SqlDatabaseTestBase<TEntity> : IAsyncDisposable
where TEntity : Entity
{
private readonly DbConnection connection;

protected SqlDatabaseTestBase()
{
connection = CreateInMemoryConnection();
var options = new DbContextOptionsBuilder()
.UseSqlite(CreateInMemoryConnection())
.UseSqlite(connection)
.Options;
DbContext = new BlogDbContext(options);
DbContextFactory = Substitute.For<IDbContextFactory<BlogDbContext>>();
Expand All @@ -35,6 +38,7 @@ public async ValueTask DisposeAsync()
{
GC.SuppressFinalize(this);
await DbContext.DisposeAsync();
await connection.DisposeAsync();
}

private static DbConnection CreateInMemoryConnection()
Expand Down

0 comments on commit 7cb2a2b

Please sign in to comment.