Archived
24 lines
637 B
C#
24 lines
637 B
C#
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();
|
|
}
|
|
}
|