XiHan.Framework.Testing
5.0.0-rc.2
Prefix Reserved
This is a prerelease version of XiHan.Framework.Testing.
dotnet add package XiHan.Framework.Testing --version 5.0.0-rc.2
NuGet\Install-Package XiHan.Framework.Testing -Version 5.0.0-rc.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XiHan.Framework.Testing" Version="5.0.0-rc.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XiHan.Framework.Testing" Version="5.0.0-rc.2" />
<PackageReference Include="XiHan.Framework.Testing" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XiHan.Framework.Testing --version 5.0.0-rc.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XiHan.Framework.Testing, 5.0.0-rc.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XiHan.Framework.Testing@5.0.0-rc.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XiHan.Framework.Testing&version=5.0.0-rc.2&prerelease
#tool nuget:?package=XiHan.Framework.Testing&version=5.0.0-rc.2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XiHan.Framework.Testing
关于
XiHan.Framework.Testing 是测试基座:没有 HTTP 的内存测试宿主、可注入行为的特性桩、按能力 ID 文本构造清单与独立调用上下文的工具。供框架、提供程序与应用的测试项目引用,也是各一致性套件装配宿主的基础。
主要特性
TestHost在内存里装配并启动应用,调用直接走完整管道StubFeature注入配置、启动、停止行为并记录事件- 不依赖宿主就能构造调用上下文
- 内存里的通行密钥认证器,按 WebAuthn 格式生成可篡改的响应
FaultyCache:可以随时切换成「缓存后端不可达」的ICache包装,测组件在缓存故障时的行为
如何使用
安装
dotnet add package XiHan.Framework.Testing --prerelease
使用
在测试里装配特性、读配置、走一次管道:
var feature = new StubFeature(TestManifests.Create("xihan.test.stub", requires: ["kernel.hosting@1"]));
await using var host = await TestHost.StartAsync(
b => b.UseFeature(feature),
configuration: [new KeyValuePair<string, string?>("XiHan:Kernel:StartTimeoutSeconds", "5")]);
var result = await host.InvokeAsync(static context =>
{
context.SetOutcome(Result.Success());
return ValueTask.CompletedTask;
});
在装配特性之前把 FaultyCache 登记为 ICache 单例,测试中途让缓存后端「断线」:
var cache = new FaultyCache(innerCache);
await using var host = await TestHost.StartAsync(b => b.UseFeature(feature), services: s => s.AddSingleton<ICache>(cache));
// 之后每个 ICache 操作都抛出携带 CACHING_UNAVAILABLE_001 的 FrameworkException
cache.Failing = true;
几个宿主登记同一个实例时共用一份缓存,可以模拟多实例共用的缓存后端。
主要类型
此库提供的主要类型:
TestHost:内存测试宿主StubFeature:可注入行为并记录事件的特性桩TestManifests:用能力 ID 文本构造清单TestInvocationContext:不依赖宿主的调用上下文WebAuthnTestAuthenticator:测试用的通行密钥认证器,生成注册与认证响应FaultyCache:可切换成缓存后端不可达的ICache包装
更多文档
反馈与贡献
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- System.Formats.Cbor (>= 10.0.15)
- System.Threading.RateLimiting (>= 10.0.14)
- XiHan.Framework.Caching.Abstractions (>= 5.0.0-rc.2)
- XiHan.Framework.Kernel (>= 5.0.0-rc.2)
- XiHan.Framework.Security.WebAuthn (>= 5.0.0-rc.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on XiHan.Framework.Testing:
| Package | Downloads |
|---|---|
|
XiHan.Framework.Localization.Conformance
曦寒框架本地化一致性测试套件 |
|
|
XiHan.Framework.Messaging.Conformance
曦寒框架消息一致性测试套件 |
|
|
XiHan.Framework.Persistence.Conformance
曦寒框架持久化一致性测试套件 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.0-rc.2 | 0 | 11/15/2026 |
| 5.0.0-rc.1 | 75 | 11/13/2026 |
| 5.0.0-preview.3 | 61 | 11/11/2026 |
| 5.0.0-preview.2 | 99 | 11/6/2026 |
| 5.0.0-preview.1 | 70 | 11/4/2026 |