yavsc/src/Yavsc.Org.Tests
Paul Schneider 61b41f0c55
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
..
Controllers test(org): isolate in-memory store per fixture 2026-08-22 04:36:52 +01:00
Fakes Introduce Yavsc.Interfaces.ISmtpClient and a recording test fake 2026-06-22 02:09:02 +01:00
Mandatory tests: log warning when OIDC token fallback is used 2026-07-12 06:43:07 +01:00
NonRegression using clauses cleanup 2026-08-22 03:34:48 +01:00
Resources Relocate test project: test/yavscTests -> src/Yavsc.Org.Tests 2026-06-19 17:52:54 +01:00
Smoke using clauses cleanup 2026-08-22 03:34:48 +01:00
appsettings.json refacto BlogPost serialization 2026-08-05 21:05:14 +01:00
ComputeKidTests.cs using clauses cleanup 2026-08-22 03:34:48 +01:00
Directory.Packages.props refactor: extract WebHostFixture + TestAuthPolicyProvider to shared lib 2026-07-06 21:33:57 +01:00
DumpHtml.cs refactoring 2026-06-19 19:59:15 +01:00
EstimateSignatureFileHelperTests.cs tests(org): forward CancellationToken to ReceiveEstimateSignatureAsync 2026-08-22 03:46:06 +01:00
StaticAssetsPathsTests.cs using clauses cleanup 2026-08-22 03:34:48 +01:00
test.runsettings fix(client-controller): single constructor with IHtmlLocalizer 2026-06-21 21:14:20 +01:00
TestUserMiddleware.cs using clauses cleanup 2026-08-22 03:34:48 +01:00
TestUserStartupFilter.cs Add comments API support and tests 2026-08-10 22:27:52 +01:00
TestWebApplicationFactory.cs test(org): isolate in-memory store per fixture 2026-08-22 04:36:52 +01:00
WebServerFixture.cs test(org): isolate in-memory store per fixture 2026-08-22 04:36:52 +01:00
xunit.runner.json Relocate test project: test/yavscTests -> src/Yavsc.Org.Tests 2026-06-19 17:52:54 +01:00
Yavsc.Org.Tests.csproj chore(release): bump version via gitversion for 1.0.8-rc1 2026-08-18 19:18:36 +01:00