Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions GFramework.Game.Tests/Config/ArchitectureConfigIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task ConfigModuleCanRunDuringArchitectureInitialization()
try
{
architecture = new ConsumerArchitecture(rootPath);
await architecture.InitializeAsync();
await architecture.InitializeAsync().ConfigureAwait(false);
initialized = true;

var table = architecture.MonsterTable;
Expand All @@ -63,7 +63,7 @@ public async Task ConfigModuleCanRunDuringArchitectureInitialization()
{
if (architecture is not null && initialized)
{
await architecture.DestroyAsync();
await architecture.DestroyAsync().ConfigureAwait(false);
}

DeleteDirectoryIfExists(rootPath);
Expand All @@ -83,7 +83,7 @@ public async Task ConfigModuleShouldLoadConfigBeforeDependentUtilityInitializati
try
{
architecture = new ConsumerArchitecture(rootPath);
await architecture.InitializeAsync();
await architecture.InitializeAsync().ConfigureAwait(false);
initialized = true;

Assert.Multiple(() =>
Expand All @@ -97,7 +97,7 @@ public async Task ConfigModuleShouldLoadConfigBeforeDependentUtilityInitializati
{
if (architecture is not null && initialized)
{
await architecture.DestroyAsync();
await architecture.DestroyAsync().ConfigureAwait(false);
}

DeleteDirectoryIfExists(rootPath);
Expand All @@ -119,16 +119,16 @@ public async Task GameConfigModuleShouldRejectReusingTheSameModuleInstance()
var module = CreateModule(rootPath);

firstArchitecture = new ModuleOnlyArchitecture(module);
await firstArchitecture.InitializeAsync();
await firstArchitecture.InitializeAsync().ConfigureAwait(false);
var wasInitializedBeforeDestroy = module.IsInitialized;
await firstArchitecture.DestroyAsync();
await firstArchitecture.DestroyAsync().ConfigureAwait(false);
firstDestroyed = true;
firstArchitecture = null;
GameContext.Clear();

var secondArchitecture = new ModuleOnlyArchitecture(module);
var exception =
Assert.ThrowsAsync<InvalidOperationException>(async () => await secondArchitecture.InitializeAsync());
Assert.ThrowsAsync<InvalidOperationException>(async () => await secondArchitecture.InitializeAsync().ConfigureAwait(false));

Assert.Multiple(() =>
{
Expand All @@ -141,7 +141,7 @@ public async Task GameConfigModuleShouldRejectReusingTheSameModuleInstance()
{
if (firstArchitecture is not null && !firstDestroyed)
{
await firstArchitecture.DestroyAsync();
await firstArchitecture.DestroyAsync().ConfigureAwait(false);
}

DeleteDirectoryIfExists(rootPath);
Expand Down Expand Up @@ -203,7 +203,7 @@ public async Task GameConfigModuleShouldRejectLateInstallationWithoutConsumingTh
var module = CreateModule(rootPath);

readyArchitecture = new ReadyOnlyArchitecture();
await readyArchitecture.InitializeAsync();
await readyArchitecture.InitializeAsync().ConfigureAwait(false);
readyArchitectureInitialized = true;

var exception = Assert.Throws<InvalidOperationException>(() => readyArchitecture.InstallModule(module));
Expand All @@ -216,13 +216,13 @@ public async Task GameConfigModuleShouldRejectLateInstallationWithoutConsumingTh
Assert.That(module.IsInitialized, Is.False);
});

await readyArchitecture.DestroyAsync();
await readyArchitecture.DestroyAsync().ConfigureAwait(false);
readyArchitectureInitialized = false;
readyArchitecture = null;
GameContext.Clear();

retryArchitecture = new ModuleOnlyArchitecture(module);
await retryArchitecture.InitializeAsync();
await retryArchitecture.InitializeAsync().ConfigureAwait(false);
retryArchitectureInitialized = true;

Assert.Multiple(() =>
Expand All @@ -235,12 +235,12 @@ public async Task GameConfigModuleShouldRejectLateInstallationWithoutConsumingTh
{
if (retryArchitecture is not null && retryArchitectureInitialized)
{
await retryArchitecture.DestroyAsync();
await retryArchitecture.DestroyAsync().ConfigureAwait(false);
}

if (readyArchitecture is not null && readyArchitectureInitialized)
{
await readyArchitecture.DestroyAsync();
await readyArchitecture.DestroyAsync().ConfigureAwait(false);
}

DeleteDirectoryIfExists(rootPath);
Expand Down
16 changes: 8 additions & 8 deletions GFramework.Game.Tests/Config/GameConfigBootstrapTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task InitializeAsync_Should_Load_Generated_Config_Tables_Into_Regis
var registry = new ConfigRegistry();
using var bootstrap = CreateBootstrap(registry);

await bootstrap.InitializeAsync();
await bootstrap.InitializeAsync().ConfigureAwait(false);

var monsterTable = registry.GetMonsterTable();

Expand All @@ -74,7 +74,7 @@ public async Task StartHotReload_Should_Update_Registered_Table_When_Config_File
CreateMonsterFiles();

using var bootstrap = CreateBootstrap();
await bootstrap.InitializeAsync();
await bootstrap.InitializeAsync().ConfigureAwait(false);

var reloadTaskSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
bootstrap.StartHotReload(
Expand All @@ -95,7 +95,7 @@ public async Task StartHotReload_Should_Update_Registered_Table_When_Config_File
faction: dungeon
""");

var tableName = await WaitForTaskWithinAsync(reloadTaskSource.Task, TimeSpan.FromSeconds(5));
var tableName = await WaitForTaskWithinAsync(reloadTaskSource.Task, TimeSpan.FromSeconds(5)).ConfigureAwait(false);
var monsterTable = bootstrap.Registry.GetMonsterTable();

Assert.Multiple(() =>
Expand Down Expand Up @@ -163,11 +163,11 @@ public void InitializeAsync_Should_Reject_Concurrent_Caller_While_Initialization
Is.True,
"The first initialization attempt did not reach the guarded lifecycle section.");

var secondCallerException = Assert.ThrowsAsync<InvalidOperationException>(async () => await bootstrap.InitializeAsync());
var secondCallerException = Assert.ThrowsAsync<InvalidOperationException>(async () => await bootstrap.InitializeAsync().ConfigureAwait(false));

continueInitialization.Set();

Assert.DoesNotThrowAsync(async () => await firstInitializeTask);
Assert.DoesNotThrowAsync(async () => await firstInitializeTask.ConfigureAwait(false));

Assert.Multiple(() =>
{
Expand Down Expand Up @@ -202,7 +202,7 @@ public void InitializeAsync_Should_Not_Publish_State_When_HotReload_Enable_Fails
})
});

var exception = Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await bootstrap.InitializeAsync());
var exception = Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await bootstrap.InitializeAsync().ConfigureAwait(false));

Assert.Multiple(() =>
{
Expand Down Expand Up @@ -311,12 +311,12 @@ private void CreateMonsterFiles()
/// <returns>任务结果。</returns>
private static async Task<T> WaitForTaskWithinAsync<T>(Task<T> task, TimeSpan timeout)
{
var completedTask = await Task.WhenAny(task, Task.Delay(timeout));
var completedTask = await Task.WhenAny(task, Task.Delay(timeout)).ConfigureAwait(false);
if (!ReferenceEquals(completedTask, task))
{
Assert.Fail($"Timed out after {timeout} while waiting for file watcher notification.");
}

return await task;
return await task.ConfigureAwait(false);
}
}
Loading
Loading