33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using System.Windows;
|
|
using VideoDownloader.App;
|
|
|
|
namespace VideoDownloader.Tests.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// 테스트 프로세스에는 App.xaml 의 리소스가 없으므로, App 어셈블리의 테마 사전을
|
|
/// 테스트 전용 Application 에 로드한다(앱의 App.ApplyTheme 과 동일 순서: 색 → 스타일).
|
|
/// </summary>
|
|
public static class WpfTestApp
|
|
{
|
|
private static bool _initialized;
|
|
|
|
public static void Ensure(System.Windows.Threading.Dispatcher dispatcher)
|
|
{
|
|
dispatcher.Invoke(() =>
|
|
{
|
|
if (_initialized) return;
|
|
if (Application.Current == null)
|
|
new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown };
|
|
var md = Application.Current.Resources.MergedDictionaries;
|
|
if (md.Count == 0)
|
|
{
|
|
const string asm = "/VideoDownloader;component";
|
|
md.Add(new ResourceDictionary { Source = new Uri(asm + "/Themes/Dark.xaml", UriKind.Relative) });
|
|
md.Add(new ResourceDictionary { Source = new Uri(asm + "/Themes/Shared.xaml", UriKind.Relative) });
|
|
}
|
|
if (!Application.Current.Resources.Contains("InverseCountToVisibility"))
|
|
Application.Current.Resources["InverseCountToVisibility"] = new InverseCountToVisibilityConverter();
|
|
_initialized = true;
|
|
});
|
|
}
|
|
}
|