Adding
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user