mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 23:49:02 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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));
|
||||
}
|
||||
Reference in New Issue
Block a user