21 lines
605 B
C#
21 lines
605 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using MoneyMap.Data;
|
|
|
|
namespace MoneyMap.Tests.TestHelpers;
|
|
|
|
public static class DbContextHelper
|
|
{
|
|
/// <summary>
|
|
/// Creates an in-memory database context for testing.
|
|
/// Each call creates a unique database to ensure test isolation.
|
|
/// </summary>
|
|
public static MoneyMapContext CreateInMemoryContext()
|
|
{
|
|
var options = new DbContextOptionsBuilder<MoneyMapContext>()
|
|
.UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
|
|
.Options;
|
|
|
|
return new MoneyMapContext(options);
|
|
}
|
|
}
|