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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 10:47:14 +00:00
1 parent 7fddd4b038
commit b6533b4c1c
1 file changed
+5 -3
@@ -290,7 +290,6 @@ public sealed class ScreenSmokeTests
/// </summary>
internal static class ScreenHost
{
private static readonly Uri SectionTemplates = new("pack://application:,,,/Titano;component/Shell/SectionTemplates.xaml", UriKind.Absolute);
private static readonly Lazy<Dispatcher> Dispatcher = new(Start, LazyThreadSafetyMode.ExecutionAndPublication);
public static Task RunAsync(Func<Task> 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;
}