From f9cc1237a3c8e2ed0db03dcb63fe0e4532ef955c Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Wed, 15 Apr 2026 16:22:09 +0800 Subject: [PATCH] =?UTF-8?q?chore(project):=20=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=9E=84=E5=92=8C=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 创建 GFramework.Core.Tests 和 GFramework.Cqrs.Tests 测试项目 - 配置测试项目的全局 using 语句和依赖引用 - 添加主项目 GFramework 的元包配置文件 - 生成解决方案文件并配置所有项目引用关系 - 设置多目标框架支持 net8.0、net9.0 和 net10.0 - 配置包发布设置和仓库信息 --- .../GFramework.Core.Tests.csproj | 2 +- GFramework.Core.Tests/GlobalUsings.cs | 2 +- .../GFramework.Cqrs.Tests.csproj | 2 +- GFramework.Cqrs.Tests/GlobalUsings.cs | 2 +- .../CqrsTestRuntime.cs | 22 ++++++++++++------- .../GFramework.Tests.Common.csproj | 17 ++++++++++++++ GFramework.csproj | 3 +++ GFramework.sln | 14 ++++++++++++ 8 files changed, 52 insertions(+), 12 deletions(-) rename {tests/Shared => GFramework.Tests.Common}/CqrsTestRuntime.cs (90%) create mode 100644 GFramework.Tests.Common/GFramework.Tests.Common.csproj diff --git a/GFramework.Core.Tests/GFramework.Core.Tests.csproj b/GFramework.Core.Tests/GFramework.Core.Tests.csproj index c455f570..391b2924 100644 --- a/GFramework.Core.Tests/GFramework.Core.Tests.csproj +++ b/GFramework.Core.Tests/GFramework.Core.Tests.csproj @@ -18,7 +18,7 @@ - + diff --git a/GFramework.Core.Tests/GlobalUsings.cs b/GFramework.Core.Tests/GlobalUsings.cs index daaaf5b7..96b8bb1a 100644 --- a/GFramework.Core.Tests/GlobalUsings.cs +++ b/GFramework.Core.Tests/GlobalUsings.cs @@ -16,7 +16,7 @@ global using System.Collections.Generic; global using System.Linq; global using System.Threading; global using System.Threading.Tasks; -global using GFramework.Tests.Shared; +global using GFramework.Tests.Common; global using NUnit.Framework; global using NUnit.Compatibility; global using GFramework.Core.Systems; diff --git a/GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj b/GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj index 6c05a59d..796883e4 100644 --- a/GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj +++ b/GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj @@ -17,7 +17,7 @@ - + diff --git a/GFramework.Cqrs.Tests/GlobalUsings.cs b/GFramework.Cqrs.Tests/GlobalUsings.cs index 9a04018e..c47473b0 100644 --- a/GFramework.Cqrs.Tests/GlobalUsings.cs +++ b/GFramework.Cqrs.Tests/GlobalUsings.cs @@ -20,7 +20,7 @@ global using System.Reflection; global using System.Runtime.CompilerServices; global using System.Threading; global using System.Threading.Tasks; -global using GFramework.Tests.Shared; +global using GFramework.Tests.Common; global using Microsoft.Extensions.DependencyInjection; global using Moq; global using NUnit.Compatibility; diff --git a/tests/Shared/CqrsTestRuntime.cs b/GFramework.Tests.Common/CqrsTestRuntime.cs similarity index 90% rename from tests/Shared/CqrsTestRuntime.cs rename to GFramework.Tests.Common/CqrsTestRuntime.cs index a234ff90..50890658 100644 --- a/tests/Shared/CqrsTestRuntime.cs +++ b/GFramework.Tests.Common/CqrsTestRuntime.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; using GFramework.Core.Abstractions.Cqrs; using GFramework.Core.Abstractions.Ioc; using GFramework.Core.Abstractions.Logging; @@ -6,16 +10,16 @@ using GFramework.Core.Ioc; using GFramework.Core.Logging; using GFramework.Cqrs.Abstractions.Cqrs; -namespace GFramework.Tests.Shared; +namespace GFramework.Tests.Common; /// /// 为测试项目提供对 CQRS 处理器真实注册入口的受控访问。 /// /// -/// 该文件以共享源码的方式同时编译进多个测试项目,确保反射绑定签名、默认 runtime 接线和注册入口行为始终保持一致, -/// 避免测试副本在独立演化后产生隐藏分歧。 +/// 该测试基础设施位于独立模块中,避免多个测试项目复制同一份反射绑定与默认 runtime 接线逻辑。 +/// 测试应通过该入口驱动注册流程,而不是各自维护一份实现细节副本。 /// -internal static class CqrsTestRuntime +public static class CqrsTestRuntime { private static readonly Type CqrsHandlerRegistrarType = typeof(ArchitectureContext).Assembly .GetType( @@ -74,11 +78,13 @@ internal static class CqrsTestRuntime /// /// 为裸测试容器补齐默认 CQRS runtime seam。 - /// 这使仅使用 的测试环境也能观察与生产路径一致的 runtime 行为, - /// 而无需完整启动服务模块管理器。 /// /// 目标测试容器。 - internal static void RegisterInfrastructure(MicrosoftDiContainer container) + /// + /// 这使仅使用 的测试环境也能观察与生产路径一致的 runtime 行为, + /// 而无需完整启动服务模块管理器。 + /// + public static void RegisterInfrastructure(MicrosoftDiContainer container) { ArgumentNullException.ThrowIfNull(container); @@ -97,7 +103,7 @@ internal static class CqrsTestRuntime /// /// 承载处理器映射的测试容器。 /// 要扫描的程序集集合。 - internal static void RegisterHandlers(MicrosoftDiContainer container, params Assembly[] assemblies) + public static void RegisterHandlers(MicrosoftDiContainer container, params Assembly[] assemblies) { ArgumentNullException.ThrowIfNull(container); ArgumentNullException.ThrowIfNull(assemblies); diff --git a/GFramework.Tests.Common/GFramework.Tests.Common.csproj b/GFramework.Tests.Common/GFramework.Tests.Common.csproj new file mode 100644 index 00000000..51f8fba9 --- /dev/null +++ b/GFramework.Tests.Common/GFramework.Tests.Common.csproj @@ -0,0 +1,17 @@ + + + + net10.0 + disable + enable + true + false + + + + + + + + + diff --git a/GFramework.csproj b/GFramework.csproj index 679cbf64..b9c6c7a4 100644 --- a/GFramework.csproj +++ b/GFramework.csproj @@ -66,6 +66,7 @@ + @@ -110,6 +111,7 @@ + @@ -140,6 +142,7 @@ + diff --git a/GFramework.sln b/GFramework.sln index 088d63d3..bc64ce21 100644 --- a/GFramework.sln +++ b/GFramework.sln @@ -44,6 +44,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Cqrs", "GFramewo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Cqrs.Tests", "GFramework.Cqrs.Tests\GFramework.Cqrs.Tests.csproj", "{29037A55-9A89-425C-AB33-D44872B2E601}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Tests.Common", "GFramework.Tests.Common\GFramework.Tests.Common.csproj", "{1100EE3E-A12D-4DE5-ABA8-591D3126570B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -318,6 +320,18 @@ Global {29037A55-9A89-425C-AB33-D44872B2E601}.Release|x64.Build.0 = Release|Any CPU {29037A55-9A89-425C-AB33-D44872B2E601}.Release|x86.ActiveCfg = Release|Any CPU {29037A55-9A89-425C-AB33-D44872B2E601}.Release|x86.Build.0 = Release|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Debug|x64.ActiveCfg = Debug|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Debug|x64.Build.0 = Debug|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Debug|x86.ActiveCfg = Debug|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Debug|x86.Build.0 = Debug|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Release|Any CPU.Build.0 = Release|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Release|x64.ActiveCfg = Release|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Release|x64.Build.0 = Release|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Release|x86.ActiveCfg = Release|Any CPU + {1100EE3E-A12D-4DE5-ABA8-591D3126570B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE