mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 修复测试架构上下文、生命周期钩子与注册表初始化钩子的评审问题,避免静默成功或错误共享状态 - 补充 TestResourceLoader、TestLogger、CapturingLoggerFactoryProvider 与 CQRS 测试辅助类型的契约文档和并发语义 - 新增测试覆盖并更新 analyzer-warning-reduction 活跃跟踪,记录 PR #300 跟进验证与现存 Cqrs warning blocker
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
using System;
|
|
using GFramework.Core.Abstractions.Logging;
|
|
using GFramework.Core.Ioc;
|
|
using GFramework.Core.Logging;
|
|
using GFramework.Cqrs.Abstractions.Cqrs;
|
|
|
|
namespace GFramework.Cqrs.Tests.Cqrs;
|
|
|
|
/// <summary>
|
|
/// 模拟局部生成注册器场景中,仅注册“可由生成代码直接引用”的那部分 handlers。
|
|
/// </summary>
|
|
internal sealed class PartialGeneratedNotificationHandlerRegistry : ICqrsHandlerRegistry
|
|
{
|
|
/// <summary>
|
|
/// 将生成路径可见的通知处理器注册到目标服务集合。
|
|
/// </summary>
|
|
/// <param name="services">承载处理器映射的服务集合。</param>
|
|
/// <param name="logger">用于记录注册诊断的日志器。</param>
|
|
/// <exception cref="ArgumentNullException">
|
|
/// <paramref name="services" /> 或 <paramref name="logger" /> 为 <see langword="null" />。
|
|
/// </exception>
|
|
public void Register(IServiceCollection services, ILogger logger)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(services);
|
|
ArgumentNullException.ThrowIfNull(logger);
|
|
|
|
services.AddTransient(
|
|
typeof(INotificationHandler<GeneratedRegistryNotification>),
|
|
typeof(GeneratedRegistryNotificationHandler));
|
|
logger.Debug(
|
|
$"Registered CQRS handler {typeof(GeneratedRegistryNotificationHandler).FullName} as {typeof(INotificationHandler<GeneratedRegistryNotification>).FullName}.");
|
|
}
|
|
}
|