Skip to content

Commit c068b29

Browse files
committed
test: improve tests
1 parent a15efb6 commit c068b29

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

tests/ByteSync.Client.IntegrationTests/TestHelpers/HeadlessIntegrationTest.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,27 @@ namespace ByteSync.Client.IntegrationTests.TestHelpers;
1414
public abstract class HeadlessIntegrationTest : IntegrationTest
1515
{
1616
private static bool _initialized;
17+
private static readonly object _setupLock = new object();
1718
// No need for a running lifetime; we will pump UI jobs manually
1819

1920
[OneTimeSetUp]
2021
public static void GlobalSetup()
2122
{
22-
if (_initialized)
23+
if (_initialized) return;
24+
25+
lock (_setupLock)
2326
{
24-
return;
25-
}
27+
if (_initialized) return;
2628

27-
AppBuilder.Configure<TestApp>()
28-
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
29-
.SetupWithoutStarting();
29+
AppBuilder.Configure<TestApp>()
30+
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
31+
.SetupWithoutStarting();
3032

31-
_initialized = true;
33+
_initialized = true;
34+
}
3235
}
3336

34-
[OneTimeTearDown]
35-
public static void GlobalTeardown()
36-
{
37-
_initialized = false;
38-
}
37+
// Do not tear down headless AppBuilder; Avalonia only supports setup once per process
3938

4039
protected Task ExecuteOnUiThread(Func<Task> action)
4140
{

0 commit comments

Comments
 (0)