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; }