Hermetic real-MainWindow tests: LayoutPathOverride temp-DB seam (InternalsVisibleTo); fix tests persisting fake webcam sources over the real layout DB; LayoutStore delete-roundtrip guard
This commit is contained in:
@@ -45,7 +45,25 @@ dotnet.exe vstest "C:\...\ytLive.Tests\bin\Debug\net8.0-windows10.0.19041.0\ytLi
|
||||
|
||||
Good Dog Rule: ONE integration test per branch, ONE test per PR. Current: TokenStore DPAPI
|
||||
roundtrip/corrupt/missing/clear, OAuth exchange/refresh/ClearSession, CameraManager refcount +
|
||||
frame pump + failure handling (fakes for the WinRT seams) — 11 passing.
|
||||
frame pump + failure handling (fakes for the WinRT seams), real-`MainWindow` round-clip
|
||||
interaction test, LayoutStore delete roundtrip — 13 passing.
|
||||
|
||||
### Real-MainWindow tests MUST be hermetic (DB pollution bug)
|
||||
|
||||
The integration test boots a real `MainWindow` → `MainViewModel` → real `LayoutStore`
|
||||
(`%APPDATA%\ytLlive\ytLlive.db`). `Shutdown()` on close **saves the layout** (full rewrite:
|
||||
DELETE all scenes/sources, re-insert), so any source a test adds would be persisted over the
|
||||
user's real ones — this happened and wiped the real webcam source (DeviceId replaced by the
|
||||
test's fake `test-camera`). Rule: a test that constructs `MainWindow` MUST first set
|
||||
`MainViewModel.LayoutPathOverride` to a temp DB path and reset it (plus
|
||||
`SqliteConnection.ClearAllPools()` + delete) in `finally`. The seam is
|
||||
`internal static string? LayoutPathOverride` (line ~529 in `MainViewModel.cs`),
|
||||
`ytLive.csproj` has `InternalsVisibleTo("ytLive.Tests")`.
|
||||
|
||||
The layout DB is a **full rewrite per save** (delete all, re-insert from memory), so
|
||||
save/load round trips are exact: a source removed in the UI (`RemoveSource` →
|
||||
`scene.Sources.Remove` → `OnSourcesChanged` → debounced `ScheduleSave`, plus `Shutdown` on
|
||||
close) does **not** come back after reload (`LayoutStorePersistenceTests` guards this).
|
||||
|
||||
## Architecture
|
||||
|
||||
|
||||
Reference in New Issue
Block a user