mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
24 lines
1.0 KiB
C#
24 lines
1.0 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
using RadicadeServer.DB;
|
|
|
|
namespace RadicadeServer.Tests;
|
|
|
|
/// <summary>
|
|
/// Builds the options every test context uses.
|
|
///
|
|
/// Each test asks for its own InMemory database, so each one needs its own
|
|
/// <see cref="DbContextOptions{TContext}"/> and EF builds a separate internal service
|
|
/// provider for it. Past twenty of those EF raises
|
|
/// <see cref="CoreEventId.ManyServiceProvidersCreatedWarning"/> as an exception, which
|
|
/// fails whichever tests happen to run after the twentieth provider rather than the test
|
|
/// that built it. That count is a property of how the harness allocates contexts, not of
|
|
/// the behaviour under test, so the warning is ignored once here instead of per test.
|
|
/// </summary>
|
|
internal static class TestDbOptions
|
|
{
|
|
public static DbContextOptionsBuilder<RecDBContext> Create() =>
|
|
new DbContextOptionsBuilder<RecDBContext>()
|
|
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning));
|
|
}
|