using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; using Xunit; namespace ytLive.Tests; /// DESIGN.md names Inter for all UI text, but a dialog is a SEPARATE WPF window: the /// FontFamily set on MainWindow never reaches it, so every dialog still rendered Segoe UI while /// the main window had moved on (found 2026-10-30). /// /// The theme now carries an implicit Window style. This test proves the mechanism on /// a real window inside the real app — which is what catches a missing resource or a broken /// implicit-style lookup — and asserts no dialog opts out by setting FontFamily itself. [Collection("RealApp")] public class DialogTypographyTests { private readonly RealAppHost _app; public DialogTypographyTests(RealAppHost app) => _app = app; [Fact] public void A_window_inherits_the_standard_typeface_and_no_dialog_opts_out() { // 1. The mechanism: any Window opened in the app resolves the token family. Dialogs are // Windows; proving it once here covers all of them, and it fails if the implicit style // or the font resource ever goes missing. _app.Run(() => { var window = new Window(); window.Show(); try { Assert.Contains("Inter", window.FontFamily?.Source ?? string.Empty, StringComparison.OrdinalIgnoreCase); } finally { window.Close(); } }); // 2. Opt-outs: a dialog that sets FontFamily itself would silently leave the standard. foreach (var file in DialogFiles()) Assert.DoesNotContain("FontFamily=", File.ReadAllText(file)); } private static IEnumerable DialogFiles() { var root = Path.GetDirectoryName(SourceAssert.RepoPath("App.xaml"))!; return Directory.EnumerateFiles(root, "*.xaml", SearchOption.AllDirectories) .Where(p => !p.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}", StringComparison.Ordinal) && !p.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}", StringComparison.Ordinal) && !p.Contains("ytLive.Tests", StringComparison.Ordinal)) .Where(p => Path.GetFileName(p).Contains("Dialog", StringComparison.OrdinalIgnoreCase) || Path.GetFileName(p).StartsWith("GoLiveWindow", StringComparison.OrdinalIgnoreCase)); } }