Archived
Project to GitHub
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Bsevita.Library.Api.Data.Generated;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Bsevita.Library.Api.Tests;
|
||||
|
||||
internal sealed class TestDatabase : IAsyncDisposable
|
||||
{
|
||||
public LibraryDbContext Context { get; private set; } = null!;
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<LibraryDbContext>()
|
||||
.UseInMemoryDatabase($"Bsevita.Library.Tests.{Guid.NewGuid():N}")
|
||||
.Options;
|
||||
Context = new LibraryDbContext(options);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await Context.DisposeAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user