yavsc/src
Paul Schneider ca9e78fb6f test(org): isolate in-memory store per fixture
TestWebApplicationFactory instances shared the same in-memory database
because EF Core's UseInMemoryDatabase("InMemory") returns the same
backing store to every DbContext that asks for it under the same
connection string, in the same process. Whichever fixture started
first defined the state, and every subsequent fixture inherited it,
making tests silently order-dependent and flaky.

Fix:

- Yavsc.Tests.Shared/InMemoryDatabaseName: helper that suffixes the
  in-memory connection string with a per-fixture GUID.
- TestWebApplicationFactory: instance GUID + ConnectionStrings__
  YavscConnection set as an environment variable in the constructor
  and cleared in Dispose, so each factory gets its own backing store.
  Env var is needed because IdentityServer8.EntityFramework exposes
  ConfigureDbContext as Action<DbContextOptionsBuilder> with no
  service-provider access, so the connection string is captured at
  registration time. AddEnvironmentVariables is the last provider in
  the config pipeline and wins regardless.
- WebServerFixture: process-static GUID (WebHostFixture is a
  per-process singleton by design, so the test collection shares one
  store; the GUID still isolates from TestWebApplicationFactory).
- AddIdentityDBAndStores: read the connection string at DbContext
  construction time via the (sp, options) overload of AddDbContext,
  so test fixtures can override it via the host's IConfiguration.
  IdentityServer stores cannot do the same without subclassing the
  framework's DbContexts; the env var path is the documented escape
  hatch in HostingExtensions.AddIdentityServer.
- UsesInMemoryProvider: StartsWith instead of equality, so
  'InMemory-{guid}' is still recognised as an in-memory connection
  string.

Regression sentinel in
Controllers/TestWebApplicationFactoryIsolationTests: two factories
seed a marker client in the first, the second must not see it.

Suite: 45/45 over 3 stable runs, 13-15s each.
2026-08-22 04:36:52 +01:00
..
cli using clauses cleanup 2026-08-22 03:34:48 +01:00
PostIt using clauses cleanup 2026-08-22 03:34:48 +01:00
PostIt.Tests using clauses cleanup 2026-08-22 03:34:48 +01:00
Yavsc.Abstract using clauses cleanup 2026-08-22 03:34:48 +01:00
Yavsc.Api using clauses cleanup 2026-08-22 03:34:48 +01:00
Yavsc.Api.Client fixes a 500 in prod and the associated test 2026-08-21 16:58:27 +01:00
Yavsc.Blogs using clauses cleanup 2026-08-22 03:34:48 +01:00
Yavsc.Blogs.Tests tests(blogs): pass TestContext.Current.CancellationToken to HTTP calls 2026-08-22 03:45:59 +01:00
Yavsc.Org test(org): isolate in-memory store per fixture 2026-08-22 04:36:52 +01:00
Yavsc.Org.Tests test(org): isolate in-memory store per fixture 2026-08-22 04:36:52 +01:00
Yavsc.Server using clauses cleanup 2026-08-22 03:34:48 +01:00
Yavsc.Tests.Shared test(org): isolate in-memory store per fixture 2026-08-22 04:36:52 +01:00