mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 08:44:29 +08:00
- 拆分 GameContextTests、ArchitectureServicesTests、RegistryInitializationHookBaseTests 与 Cqrs 测试辅助类型,消除批次内 MA0048 热点 - 修复 Core.Tests 零散可空性、集合抽象和测试辅助 warning,使受影响 Release 构建清零 - 更新 analyzer-warning-reduction 跟踪与 trace,记录 236 条仓库根 warning 基线和 45/50 停止点
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using GFramework.Core.Abstractions.Enums;
|
|
using GFramework.Core.Architectures;
|
|
|
|
namespace GFramework.Core.Tests.Architectures;
|
|
|
|
/// <summary>
|
|
/// 测试架构基类,提供通用的测试架构功能
|
|
/// </summary>
|
|
public abstract class TestArchitectureBase : Architecture
|
|
{
|
|
private Action<TestArchitectureBase>? _postRegistrationHook;
|
|
private readonly List<ArchitecturePhase> _phaseHistory = [];
|
|
|
|
/// <summary>
|
|
/// 获取就绪事件是否已触发的状态
|
|
/// </summary>
|
|
public bool ReadyEventFired { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// 获取初始化方法是否已调用的状态
|
|
/// </summary>
|
|
public bool InitCalled { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// 获取架构阶段历史记录列表
|
|
/// </summary>
|
|
public IReadOnlyList<ArchitecturePhase> PhaseHistory => _phaseHistory;
|
|
|
|
/// <summary>
|
|
/// 添加注册后钩子函数
|
|
/// </summary>
|
|
/// <param name="hook">要添加的钩子函数</param>
|
|
public void AddPostRegistrationHook(Action<TestArchitectureBase> hook)
|
|
{
|
|
_postRegistrationHook = hook;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化架构组件,注册模型、系统并设置事件监听器
|
|
/// </summary>
|
|
protected override void OnInitialize()
|
|
{
|
|
InitCalled = true;
|
|
_postRegistrationHook?.Invoke(this);
|
|
|
|
// 订阅阶段变更事件以记录历史
|
|
PhaseChanged += (_, eventArgs) => _phaseHistory.Add(eventArgs.Phase);
|
|
}
|
|
}
|