mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 创建 AsyncTestArchitecture 类用于异步测试 - 添加 AsyncTestSystem 实现异步初始化系统 - 创建 ArchitectureTestsBase 基类统一同步异步测试逻辑 - 实现 AsyncArchitectureTests 异步架构测试用例 - 将同步测试重构为继承自 ArchitectureTestsBase - 移除重复的测试方法实现 - 重命名模型初始化状态属性为 Initialized
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using GFramework.Core.Abstractions.architecture;
|
|
using GFramework.Core.Abstractions.enums;
|
|
using GFramework.Core.Abstractions.system;
|
|
|
|
namespace GFramework.Core.Tests.system;
|
|
|
|
/// <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);
|
|
Initialized = true;
|
|
}
|
|
|
|
public void SetContext(IArchitectureContext context) => _context = context;
|
|
public IArchitectureContext GetContext() => _context;
|
|
|
|
public void Init()
|
|
{
|
|
// 同步 Init 不应该被调用
|
|
throw new InvalidOperationException("Sync Init should not be called");
|
|
}
|
|
|
|
public void Destroy() => DestroyCalled = true;
|
|
|
|
public void OnArchitecturePhase(ArchitecturePhase phase)
|
|
{
|
|
}
|
|
} |