mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-06 16:16:44 +08:00
fix(cqrs-tests): 拆分处理器注册测试辅助类型
- 拆分 CqrsHandlerRegistrarTests 尾部的测试辅助类型到同目录同名文件 - 保持 CQRS handler registrar 测试行为与 XML 文档不变并消除该切片的 MA0048 warning
This commit is contained in:
parent
54530d31d9
commit
98afcbffb3
@ -0,0 +1,23 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GFramework.Cqrs.Abstractions.Cqrs;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 名称排序上应先于 Zeta 处理器执行的通知处理器。
|
||||
/// </summary>
|
||||
internal sealed class AlphaDeterministicNotificationHandler : INotificationHandler<DeterministicOrderNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录当前处理器已执行。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(DeterministicOrderNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
DeterministicNotificationHandlerState.InvocationOrder.Add(nameof(AlphaDeterministicNotificationHandler));
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
49
GFramework.Cqrs.Tests/Cqrs/CapturingLoggerFactoryProvider.cs
Normal file
49
GFramework.Cqrs.Tests/Cqrs/CapturingLoggerFactoryProvider.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using GFramework.Core.Abstractions.Logging;
|
||||
using GFramework.Core.Logging;
|
||||
using GFramework.Cqrs.Tests.Logging;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 为 CQRS 注册测试捕获真实启动路径中创建的日志记录器。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 处理器注册入口会分别为测试运行时、容器和注册器创建日志器。
|
||||
/// 该提供程序统一保留这些测试日志器,以便断言警告是否经由公开入口真正发出。
|
||||
/// </remarks>
|
||||
internal sealed class CapturingLoggerFactoryProvider : ILoggerFactoryProvider
|
||||
{
|
||||
private readonly List<TestLogger> _loggers = [];
|
||||
|
||||
/// <summary>
|
||||
/// 使用指定的最小日志级别初始化一个新的捕获型日志工厂提供程序。
|
||||
/// </summary>
|
||||
/// <param name="minLevel">要应用到新建测试日志器的最小日志级别。</param>
|
||||
public CapturingLoggerFactoryProvider(LogLevel minLevel = LogLevel.Info)
|
||||
{
|
||||
MinLevel = minLevel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取通过当前提供程序创建的全部测试日志器。
|
||||
/// </summary>
|
||||
public IReadOnlyList<TestLogger> Loggers => _loggers;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置新建测试日志器的最小日志级别。
|
||||
/// </summary>
|
||||
public LogLevel MinLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建一个测试日志器并将其纳入捕获集合。
|
||||
/// </summary>
|
||||
/// <param name="name">日志记录器名称。</param>
|
||||
/// <returns>用于后续断言的测试日志器。</returns>
|
||||
public ILogger CreateLogger(string name)
|
||||
{
|
||||
var logger = new TestLogger(name, MinLevel);
|
||||
_loggers.Add(logger);
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
@ -614,230 +614,3 @@ internal sealed class CqrsHandlerRegistrarTests
|
||||
.GetType("GFramework.Cqrs.Internal.CqrsHandlerRegistrar", throwOnError: true)!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录确定性通知处理器的实际执行顺序。
|
||||
/// </summary>
|
||||
internal static class DeterministicNotificationHandlerState
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前测试中的通知处理器执行顺序。
|
||||
/// </summary>
|
||||
public static List<string> InvocationOrder { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 重置共享的执行顺序状态。
|
||||
/// </summary>
|
||||
public static void Reset()
|
||||
{
|
||||
InvocationOrder.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于验证同一通知的多个处理器是否按稳定顺序执行。
|
||||
/// </summary>
|
||||
internal sealed record DeterministicOrderNotification : INotification;
|
||||
|
||||
/// <summary>
|
||||
/// 故意放在 Alpha 之前声明,用于验证注册器不会依赖源码声明顺序。
|
||||
/// </summary>
|
||||
internal sealed class ZetaDeterministicNotificationHandler : INotificationHandler<DeterministicOrderNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录当前处理器已执行。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(DeterministicOrderNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
DeterministicNotificationHandlerState.InvocationOrder.Add(nameof(ZetaDeterministicNotificationHandler));
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 名称排序上应先于 Zeta 处理器执行的通知处理器。
|
||||
/// </summary>
|
||||
internal sealed class AlphaDeterministicNotificationHandler : INotificationHandler<DeterministicOrderNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录当前处理器已执行。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(DeterministicOrderNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
DeterministicNotificationHandlerState.InvocationOrder.Add(nameof(AlphaDeterministicNotificationHandler));
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为 CQRS 注册测试捕获真实启动路径中创建的日志记录器。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 处理器注册入口会分别为测试运行时、容器和注册器创建日志器。
|
||||
/// 该提供程序统一保留这些测试日志器,以便断言警告是否经由公开入口真正发出。
|
||||
/// </remarks>
|
||||
internal sealed class CapturingLoggerFactoryProvider : ILoggerFactoryProvider
|
||||
{
|
||||
private readonly List<TestLogger> _loggers = [];
|
||||
|
||||
/// <summary>
|
||||
/// 使用指定的最小日志级别初始化一个新的捕获型日志工厂提供程序。
|
||||
/// </summary>
|
||||
/// <param name="minLevel">要应用到新建测试日志器的最小日志级别。</param>
|
||||
public CapturingLoggerFactoryProvider(LogLevel minLevel = LogLevel.Info)
|
||||
{
|
||||
MinLevel = minLevel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取通过当前提供程序创建的全部测试日志器。
|
||||
/// </summary>
|
||||
public IReadOnlyList<TestLogger> Loggers => _loggers;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置新建测试日志器的最小日志级别。
|
||||
/// </summary>
|
||||
public LogLevel MinLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建一个测试日志器并将其纳入捕获集合。
|
||||
/// </summary>
|
||||
/// <param name="name">日志记录器名称。</param>
|
||||
/// <returns>用于后续断言的测试日志器。</returns>
|
||||
public ILogger CreateLogger(string name)
|
||||
{
|
||||
var logger = new TestLogger(name, MinLevel);
|
||||
_loggers.Add(logger);
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于验证生成注册器路径的通知消息。
|
||||
/// </summary>
|
||||
internal sealed record GeneratedRegistryNotification : INotification;
|
||||
|
||||
/// <summary>
|
||||
/// 由模拟的源码生成注册器显式注册的通知处理器。
|
||||
/// </summary>
|
||||
internal sealed class GeneratedRegistryNotificationHandler : INotificationHandler<GeneratedRegistryNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理生成注册器测试中的通知。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(GeneratedRegistryNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模拟源码生成器为某个程序集生成的 CQRS 处理器注册器。
|
||||
/// </summary>
|
||||
internal sealed class GeneratedNotificationHandlerRegistry : ICqrsHandlerRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// 将测试通知处理器注册到目标服务集合。
|
||||
/// </summary>
|
||||
/// <param name="services">承载处理器映射的服务集合。</param>
|
||||
/// <param name="logger">用于记录注册诊断的日志器。</param>
|
||||
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}.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于验证“生成注册器 + reflection fallback”组合路径的私有嵌套处理器容器。
|
||||
/// </summary>
|
||||
internal sealed class ReflectionFallbackNotificationContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取仅能通过反射补扫接入的私有嵌套处理器类型。
|
||||
/// </summary>
|
||||
public static Type ReflectionOnlyHandlerType => typeof(ReflectionOnlyGeneratedRegistryNotificationHandler);
|
||||
|
||||
private sealed class ReflectionOnlyGeneratedRegistryNotificationHandler
|
||||
: INotificationHandler<GeneratedRegistryNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理测试通知。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(GeneratedRegistryNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模拟局部生成注册器场景中,仅注册“可由生成代码直接引用”的那部分 handlers。
|
||||
/// </summary>
|
||||
internal sealed class PartialGeneratedNotificationHandlerRegistry : ICqrsHandlerRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// 将生成路径可见的通知处理器注册到目标服务集合。
|
||||
/// </summary>
|
||||
/// <param name="services">承载处理器映射的服务集合。</param>
|
||||
/// <param name="logger">用于记录注册诊断的日志器。</param>
|
||||
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}.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模拟生成注册器使用私有无参构造器的场景,验证运行时仍可通过缓存工厂激活它。
|
||||
/// </summary>
|
||||
internal sealed class PrivateConstructorNotificationHandlerRegistry : ICqrsHandlerRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化一个新的私有生成注册器实例。
|
||||
/// </summary>
|
||||
private PrivateConstructorNotificationHandlerRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将测试通知处理器注册到目标服务集合。
|
||||
/// </summary>
|
||||
/// <param name="services">承载处理器映射的服务集合。</param>
|
||||
/// <param name="logger">用于记录注册诊断的日志器。</param>
|
||||
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}.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 记录确定性通知处理器的实际执行顺序。
|
||||
/// </summary>
|
||||
internal static class DeterministicNotificationHandlerState
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前测试中的通知处理器执行顺序。
|
||||
/// </summary>
|
||||
public static List<string> InvocationOrder { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 重置共享的执行顺序状态。
|
||||
/// </summary>
|
||||
public static void Reset()
|
||||
{
|
||||
InvocationOrder.Clear();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using GFramework.Cqrs.Abstractions.Cqrs;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 用于验证同一通知的多个处理器是否按稳定顺序执行。
|
||||
/// </summary>
|
||||
internal sealed record DeterministicOrderNotification : INotification;
|
||||
@ -0,0 +1,30 @@
|
||||
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>
|
||||
/// 模拟源码生成器为某个程序集生成的 CQRS 处理器注册器。
|
||||
/// </summary>
|
||||
internal sealed class GeneratedNotificationHandlerRegistry : ICqrsHandlerRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// 将测试通知处理器注册到目标服务集合。
|
||||
/// </summary>
|
||||
/// <param name="services">承载处理器映射的服务集合。</param>
|
||||
/// <param name="logger">用于记录注册诊断的日志器。</param>
|
||||
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}.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using GFramework.Cqrs.Abstractions.Cqrs;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 用于验证生成注册器路径的通知消息。
|
||||
/// </summary>
|
||||
internal sealed record GeneratedRegistryNotification : INotification;
|
||||
@ -0,0 +1,22 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GFramework.Cqrs.Abstractions.Cqrs;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 由模拟的源码生成注册器显式注册的通知处理器。
|
||||
/// </summary>
|
||||
internal sealed class GeneratedRegistryNotificationHandler : INotificationHandler<GeneratedRegistryNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理生成注册器测试中的通知。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(GeneratedRegistryNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
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>
|
||||
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}.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
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>
|
||||
/// 模拟生成注册器使用私有无参构造器的场景,验证运行时仍可通过缓存工厂激活它。
|
||||
/// </summary>
|
||||
internal sealed class PrivateConstructorNotificationHandlerRegistry : ICqrsHandlerRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化一个新的私有生成注册器实例。
|
||||
/// </summary>
|
||||
private PrivateConstructorNotificationHandlerRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将测试通知处理器注册到目标服务集合。
|
||||
/// </summary>
|
||||
/// <param name="services">承载处理器映射的服务集合。</param>
|
||||
/// <param name="logger">用于记录注册诊断的日志器。</param>
|
||||
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}.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GFramework.Cqrs.Abstractions.Cqrs;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 用于验证“生成注册器 + reflection fallback”组合路径的私有嵌套处理器容器。
|
||||
/// </summary>
|
||||
internal sealed class ReflectionFallbackNotificationContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取仅能通过反射补扫接入的私有嵌套处理器类型。
|
||||
/// </summary>
|
||||
public static Type ReflectionOnlyHandlerType => typeof(ReflectionOnlyGeneratedRegistryNotificationHandler);
|
||||
|
||||
private sealed class ReflectionOnlyGeneratedRegistryNotificationHandler
|
||||
: INotificationHandler<GeneratedRegistryNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理测试通知。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(GeneratedRegistryNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GFramework.Cqrs.Abstractions.Cqrs;
|
||||
|
||||
namespace GFramework.Cqrs.Tests.Cqrs;
|
||||
|
||||
/// <summary>
|
||||
/// 故意放在 Alpha 之前声明,用于验证注册器不会依赖源码声明顺序。
|
||||
/// </summary>
|
||||
internal sealed class ZetaDeterministicNotificationHandler : INotificationHandler<DeterministicOrderNotification>
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录当前处理器已执行。
|
||||
/// </summary>
|
||||
/// <param name="notification">通知实例。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>已完成任务。</returns>
|
||||
public ValueTask Handle(DeterministicOrderNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
DeterministicNotificationHandlerState.InvocationOrder.Add(nameof(ZetaDeterministicNotificationHandler));
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user