Added more UI logic. Added a manga pipeline test.
This commit is contained in:
36
MangaReader.Tests/Utilities/TestDbContextFactory.cs
Normal file
36
MangaReader.Tests/Utilities/TestDbContextFactory.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using MangaReader.Core.Data;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace MangaReader.Tests.Utilities;
|
||||
|
||||
public class TestDbContextFactory : IDisposable
|
||||
{
|
||||
private readonly SqliteConnection _connection;
|
||||
private readonly DbContextOptions<MangaContext> _options;
|
||||
|
||||
public TestDbContextFactory()
|
||||
{
|
||||
_connection = new SqliteConnection("DataSource=:memory:");
|
||||
_connection.Open();
|
||||
|
||||
_options = new DbContextOptionsBuilder<MangaContext>()
|
||||
.UseSqlite(_connection)
|
||||
.EnableSensitiveDataLogging() // Optional: helps with debugging
|
||||
.Options;
|
||||
|
||||
using MangaContext context = new(_options);
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public MangaContext CreateContext()
|
||||
{
|
||||
return new MangaContext(_options);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_connection.Close();
|
||||
_connection.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user