Files
HashTool/tests/HashTool.App.Tests/TestApp.cs
T
poli0981andClaude Opus 5.5 9e06e7cadd test(app): one Avalonia application for the whole test run
Avalonia 12 creates an application per test by default, so the app's
startup ran again for every test, and its asynchronous part (system font
loading, then applying the settings) could land on the dispatcher of a
later test: "The calling thread cannot access this object" on cleanup,
seen on macOS CI and now and then on Windows. The app itself has one
application per process, and so do the tests now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 08:02:08 +07:00

19 lines
777 B
C#

using Avalonia;
using Avalonia.Headless;
using HashTool.App.Tests;
[assembly: AvaloniaTestApplication(typeof(TestApp))]
// One application for the whole run, like the app itself. With a new one per test, the asynchronous part of the app's
// startup (font loading, then applying the settings) of one test lands on the dispatcher of a later one.
[assembly: AvaloniaTestIsolation(AvaloniaTestIsolationLevel.PerAssembly)]
namespace HashTool.App.Tests;
/// <summary>Runs the real <see cref="App"/> on Avalonia's headless platform (data folder: see <see cref="TestEnvironment"/>).</summary>
public static class TestApp
{
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>().UseHeadless(new AvaloniaHeadlessPlatformOptions()).WithInterFont();
}