namespace Yavsc.Tests.Shared; /// /// Helpers for the in-memory connection string used by test fixtures. /// /// EF Core's UseInMemoryDatabase(name) returns the same backing /// store to every DbContext that asks for it under the same /// , in the same process. That means every /// fixture that uses the bare "InMemory" connection string /// shares the same in-memory database — which leaks state between /// fixtures that are supposed to be independent, and silently makes /// tests order-dependent. /// /// The fix is to give each fixture its own suffix. /// returns a stable, fixture-scoped connection string. The fixture /// stores the suffix in an instance field so successive calls within /// the same fixture always resolve to the same database. /// public static class InMemoryDatabaseName { /// Base connection string for the in-memory provider, /// as it appears in appsettings-org.Testing.json. public const string Base = "InMemory"; /// Builds a per-fixture connection string. Two calls /// with the same return the same /// string; two calls with different ids return different /// strings, isolating the underlying in-memory stores. public static string For(string fixtureId) => $"{Base}-{fixtureId}"; }