using Microsoft.EntityFrameworkCore;
using ProposalSystem.Infrastructure.Data;
namespace ProposalSystem.Tests.Helpers;
///
/// Creates isolated in-memory DbContext instances for unit tests.
/// Each call produces a uniquely-named database so tests don't leak state.
///
public static class DbContextFactory
{
public static ProposalDbContext Create()
{
var options = new DbContextOptionsBuilder()
.UseInMemoryDatabase(databaseName: $"TestDb_{Guid.NewGuid()}")
.Options;
var context = new ProposalDbContext(options);
context.Database.EnsureCreated();
return context;
}
}