// Copyright (c) 2025-2026 GeWuYou
// SPDX-License-Identifier: Apache-2.0
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using GFramework.Core.Abstractions.Architectures;
using GFramework.Core.Abstractions.Lifecycle;
using GFramework.Core.Abstractions.Model;
using GFramework.Core.Abstractions.Systems;
using GFramework.Core.Abstractions.Utility;
namespace GFramework.Core.Tests.Architectures;
///
/// 为 提供已挂接 的架构测试替身。
///
public class TestArchitectureWithRegistry : IArchitecture
{
///
/// 使用给定测试注册表创建架构测试替身。
///
/// 要通过架构上下文暴露给钩子的测试注册表。
public TestArchitectureWithRegistry(TestRegistry registry)
{
Context = new TestArchitectureContextWithRegistry(registry);
}
///
/// 获取测试替身公开的服务配置入口。
/// 当前切片不验证服务配置流程,因此始终保持为空。
///
public Action? Configurator { get; }
///
/// 获取当前测试替身使用的架构上下文。
///
public IArchitectureContext Context { get; }
Action? IArchitecture.Configurator => Configurator;
T IArchitecture.RegisterSystem(T system)
{
throw new NotSupportedException();
}
T IArchitecture.RegisterModel(T model)
{
throw new NotSupportedException();
}
T IArchitecture.RegisterUtility(T utility)
{
throw new NotSupportedException();
}
///
/// 测试替身未实现 CQRS 管道行为注册。
///
/// 行为类型。
/// 该测试替身不参与 CQRS 管道配置验证。
public void RegisterCqrsPipelineBehavior() where TBehavior : class
{
throw new NotSupportedException();
}
///
/// 测试替身未实现显式程序集 CQRS 处理器接入入口。
///
/// 包含 CQRS 处理器或生成注册器的程序集。
/// 该测试替身不参与 CQRS 程序集接入路径验证。
public void RegisterCqrsHandlersFromAssembly(Assembly assembly)
{
throw new NotSupportedException();
}
///
/// 测试替身未实现显式程序集 CQRS 处理器接入入口。
///
/// 要接入的程序集集合。
/// 该测试替身不参与 CQRS 程序集接入路径验证。
public void RegisterCqrsHandlersFromAssemblies(IEnumerable assemblies)
{
throw new NotSupportedException();
}
///
/// 测试替身未实现模块安装流程。
///
/// 要安装的模块。
/// 此方法始终抛出异常,不返回模块实例。
/// 该测试替身不参与模块安装路径验证。
public IArchitectureModule InstallModule(IArchitectureModule module)
{
throw new NotSupportedException();
}
IArchitectureLifecycleHook IArchitecture.RegisterLifecycleHook(IArchitectureLifecycleHook hook)
{
RegisterLifecycleHook(hook);
return hook;
}
Task IArchitecture.WaitUntilReadyAsync()
{
return WaitUntilReadyAsync();
}
///
/// 测试替身未实现工具延迟注册入口。
///
/// 工具类型。
/// 工具创建后的回调。
/// 该测试替身不参与工具注册路径验证。
public void RegisterUtility(Action? onCreated = default) where T : class, IUtility
{
throw new NotSupportedException();
}
///
/// 测试替身未实现 Model 延迟注册入口。
///
/// Model 类型。
/// Model 创建后的回调。
/// 该测试替身不参与 Model 注册路径验证。
public void RegisterModel(Action? onCreated = default) where T : class, IModel
{
throw new NotSupportedException();
}
///
/// 测试替身未实现 System 延迟注册入口。
///
/// System 类型。
/// System 创建后的回调。
/// 该测试替身不参与 System 注册路径验证。
public void RegisterSystem(Action? onCreated = default) where T : class, ISystem
{
throw new NotSupportedException();
}
///
/// 初始化测试替身。
/// 该切片只需要上下文可用,因此初始化过程保持为空实现。
///
public void Initialize()
{
}
///
/// 测试替身未实现销毁路径。
///
/// 该测试替身不参与销毁路径验证。
public void Destroy()
{
throw new NotSupportedException();
}
Task IAsyncInitializable.InitializeAsync()
{
return InitializeAsync();
}
ValueTask IAsyncDestroyable.DestroyAsync()
{
return DestroyAsync();
}
///
/// 测试替身未实现就绪等待流程。
///
/// 此方法始终抛出异常,不返回等待任务。
/// 该测试替身不参与就绪等待路径验证。
public Task WaitUntilReadyAsync()
{
throw new NotSupportedException();
}
///
/// 注册架构生命周期钩子。
/// 当前切片不依赖生命周期钩子执行,因此保持空实现。
///
/// 要忽略的生命周期钩子。
public void RegisterLifecycleHook(IArchitectureLifecycleHook hook)
{
}
///
/// 测试替身未实现异步初始化路径。
///
/// 此方法始终抛出异常,不返回初始化任务。
/// 该测试替身不参与异步初始化验证。
public Task InitializeAsync()
{
throw new NotSupportedException();
}
///
/// 测试替身未实现异步销毁路径。
///
/// 此方法始终抛出异常,不返回销毁任务。
/// 该测试替身不参与异步销毁验证。
public ValueTask DestroyAsync()
{
throw new NotSupportedException();
}
}