From b6533b4c1c07e1ba6f3df54a4cfd5ec27dc46f30 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 10:47:14 +0000 Subject: [PATCH] test(app): build the section templates pack URI after the Application exists The Server screen smoke tests now run before any other WPF test, so ScreenHost's static pack:// URI was parsed before the scheme was registered and every later screen test failed with a type initializer exception. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs b/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs index bc8647fc..a1ab74eb 100644 --- a/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs +++ b/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs @@ -290,7 +290,6 @@ public sealed class ScreenSmokeTests /// internal static class ScreenHost { - private static readonly Uri SectionTemplates = new("pack://application:,,,/Titano;component/Shell/SectionTemplates.xaml", UriKind.Absolute); private static readonly Lazy Dispatcher = new(Start, LazyThreadSafetyMode.ExecutionAndPublication); public static Task RunAsync(Func body) => Dispatcher.Value.InvokeAsync(body).Task.Unwrap(); @@ -317,10 +316,13 @@ internal static class ScreenHost } dispatcher!.Invoke(() => { + // pack:// URIs parse only once an Application exists (it registers the scheme), so this one is built here, + // not in a static field: the first WPF test of a run may be the one that starts the Application. + var sectionTemplates = new Uri("pack://application:,,,/Titano;component/Shell/SectionTemplates.xaml", UriKind.Absolute); var current = Application.Current; AppResources.Merge(current); - if (!current.Resources.MergedDictionaries.Any(d => d.Source == SectionTemplates)) - current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = SectionTemplates }); + if (!current.Resources.MergedDictionaries.Any(d => d.Source == sectionTemplates)) + current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = sectionTemplates }); }); return dispatcher; }