31 lines
946 B
C#
31 lines
946 B
C#
using System;
|
|
using LCU.Shared.Collections.RepoApiLib.Persistence;
|
|
using Microsoft.Data.Sqlite;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace LCU.API.Collections.RepoApiTests.Repository
|
|
{
|
|
public abstract class TestWithSqlite : IDisposable
|
|
{
|
|
private const string InMemoryConnectionString = "DataSource=:memory:";
|
|
private readonly SqliteConnection _connection;
|
|
|
|
protected readonly AppDbContext SqliteDbContext;
|
|
|
|
protected TestWithSqlite()
|
|
{
|
|
_connection = new SqliteConnection(InMemoryConnectionString);
|
|
_connection.Open();
|
|
var options = new DbContextOptionsBuilder<AppDbContext>()
|
|
.UseSqlite(_connection)
|
|
.Options;
|
|
SqliteDbContext = new AppDbContext(options);
|
|
SqliteDbContext.Database.EnsureCreated();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_connection.Close();
|
|
}
|
|
}
|
|
} |