using Avalonia; using Avalonia.Headless; using Avalonia.Markup.Xaml.Styling; using AvParser.UI.HeadlessTests; using ReactiveUI.Avalonia; using Semi.Avalonia; [assembly: AvaloniaTestApplication(typeof(TestAppBuilder))] // The headless platform is one dispatcher per assembly; running collections in parallel produces // intermittent "call from invalid thread" failures rather than useful signal. [assembly: CollectionBehavior(DisableTestParallelization = true)] namespace AvParser.UI.HeadlessTests; /// Boots a headless Avalonia application for [AvaloniaFact] tests. public static class TestAppBuilder { /// Called by Avalonia.Headless.XUnit once per test assembly. public static AppBuilder BuildAvaloniaApp() => AppBuilder .Configure() .UseHeadless(new AvaloniaHeadlessPlatformOptions()) .UseReactiveUI(_ => { }); } /// /// A minimal application that loads the real styles but never touches the DI container. /// /// /// Deliberately not AvParser.Desktop.App: these tests should exercise the views and the /// stylesheet, not Serilog, the settings file or the composition root. Styles are added in code /// rather than XAML so the test project needs no Avalonia XAML compilation of its own. /// public sealed class HeadlessTestApp : Application { /// public override void Initialize() { Styles.Add(new SemiTheme()); var index = new Uri("avares://AvParser.UI/Styles/Index.axaml"); Styles.Add(new StyleInclude(index) { Source = index }); } }