mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 17:21:16 +08:00
- 更新 ArchitectureContext、ArchitectureServices、GameContext 与环境测试桩的异常类型以满足 analyzer 约束 - 补齐 AsyncTestModel 与 AsyncTestSystem 的异步等待配置并保持测试语义不变 - 调整 ResultTests 的异类异常断言样例以避免新增编译与 analyzer 噪音
48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using GFramework.Core.Abstractions.Architectures;
|
|
using GFramework.Core.Abstractions.Enums;
|
|
using GFramework.Core.Abstractions.Lifecycle;
|
|
using GFramework.Core.Abstractions.Systems;
|
|
|
|
namespace GFramework.Core.Tests.Systems;
|
|
|
|
/// <summary>
|
|
/// 异步测试系统,实现 ISystem 和 IAsyncInitializable
|
|
/// </summary>
|
|
public sealed class AsyncTestSystem : ISystem, IAsyncInitializable
|
|
{
|
|
private IArchitectureContext _context = null!;
|
|
public bool Initialized { get; private set; }
|
|
public bool DestroyCalled { get; private set; }
|
|
|
|
public async Task InitializeAsync()
|
|
{
|
|
await Task.Delay(10).ConfigureAwait(false);
|
|
Initialized = true;
|
|
}
|
|
|
|
public void SetContext(IArchitectureContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public IArchitectureContext GetContext()
|
|
{
|
|
return _context;
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
// 同步 OnInitialize 不应该被调用
|
|
throw new InvalidOperationException("Sync OnInitialize should not be called");
|
|
}
|
|
|
|
public void Destroy()
|
|
{
|
|
DestroyCalled = true;
|
|
}
|
|
|
|
public void OnArchitecturePhase(ArchitecturePhase phase)
|
|
{
|
|
}
|
|
}
|