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:
2026-08-06 15:16:58 -07:00
parent 7bc70872d9
commit f31ce9fdb7
5 changed files with 90 additions and 2 deletions
@@ -5,6 +5,7 @@ using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Threading;
using Microsoft.Data.Sqlite;
using Xunit;
using ytLive.Models;
using ytLive.ViewModels;
@@ -47,6 +48,11 @@ public sealed class RoundClipInteractionTests
var app = new App();
app.InitializeComponent();
// Never let the real MainWindow read/write the user's actual layout DB —
// Shutdown() saves the layout, which would persist these test sources
// over the real ones. Point it at a throwaway temp DB instead.
var tempDb = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"ytLlive-test-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = tempDb;
var window = new MainWindow();
var vm = (MainViewModel)window.DataContext;
try
@@ -103,6 +109,9 @@ public sealed class RoundClipInteractionTests
finally
{
window.Close();
MainViewModel.LayoutPathOverride = null;
SqliteConnection.ClearAllPools();
try { System.IO.File.Delete(tempDb); } catch { /* best-effort cleanup */ }
}
}