VelaShell.PluginSdk.Testing 2.1.4

dotnet add package VelaShell.PluginSdk.Testing --version 2.1.4
                    
NuGet\Install-Package VelaShell.PluginSdk.Testing -Version 2.1.4
                    
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="VelaShell.PluginSdk.Testing" Version="2.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VelaShell.PluginSdk.Testing" Version="2.1.4" />
                    
Directory.Packages.props
<PackageReference Include="VelaShell.PluginSdk.Testing" />
                    
Project file
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 VelaShell.PluginSdk.Testing --version 2.1.4
                    
#r "nuget: VelaShell.PluginSdk.Testing, 2.1.4"
                    
#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 VelaShell.PluginSdk.Testing@2.1.4
                    
#: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=VelaShell.PluginSdk.Testing&version=2.1.4
                    
Install as a Cake Addin
#tool nuget:?package=VelaShell.PluginSdk.Testing&version=2.1.4
                    
Install as a Cake Tool

VelaShell.PluginSdk.Testing

插件单元测试替身包:TestPluginContext + 全部能力接口的内存实现。

插件项目引用本包后,无需启动宿主、无需数据库、不发一次网络请求即可对业务逻辑做纯内存单测。

🗂️ 替身清单

类型 替代的能力
TestPluginContext IPluginContext 本体,聚合下列全部替身并暴露为强类型字段。
InMemoryStorage IPluginStorage(KV 存储)。
FakeSecretsAndClipboard ISecretsApi(机密)与 IClipboardApi(剪贴板)。
InMemoryTimeSeries ITimeSeriesApi(时序写入与查询)。
FakeSessions ISessionsApi:AddConnected(...) 造一条已连接会话,AddSaved(...) 造一条已保存配置;DenyOpen / OpenFailure 模拟「用户点了不」与「连不上」,LastOpenReason 用来断言那句给用户看的理由确实传上去了。
FakeRemoteExec IRemoteExecApi:用 Handler 委托按命令文本给定输出。
FakeRemoteFs IRemoteFsApi(远程文件读写与列目录)。独立传输任务的每个方法都要显式打开能力位(SupportsTransferOperations / SupportsDownloadOperations / SupportsTransferWithdraw)并配上对应的 *Handler 才可用,否则明确抛不支持;请求逐条记在 UploadsStarted / TransfersCancelled / TransfersWithdrawn 等列表里。宿主的幂等、审批与「批准与撤回先到者赢」由测试脚本自己模拟,替身不编造结论。
FakeTerminal ITerminalApi(读终端尾部输出、回写终端)。
FakeUi IUiApi(面板与消息中心通知):PostedNotifications 是实际进列表的消息,NotificationRequests 是全部投递;与宿主同一套校验与同 id 去重,NotificationOutcome 脚本模拟限流 / 静音,SupportsNotifications = false 模拟旧宿主。
RecordingCommands ICommandsApi:记录注册的命令,可用 RunAsync(id) 直接触发。
TestHostEvents IHostEvents:手动投递宿主事件。
CollectingLogger IPluginLogger:收集日志行供断言。

用法

using var ctx = new TestPluginContext();
SessionInfo session = ctx.FakeSessions.AddConnected(host: "prod-1");
ctx.FakeRemoteExec.Handler = (_, cmd) => cmd == "docker ps" ? "CONTAINER ID ..." : "";

var plugin = new MyPlugin();
await plugin.ActivateAsync(ctx, CancellationToken.None);
await ctx.RecordingCommands.RunAsync("my.plugin.refresh");

真实用例见 tests/VelaShell.Plugin.Ai.Tests —— AI 插件的工具审批闸门、设置/机密存取与会话历史全部靠这套替身覆盖。

用法详解见 开发指南,测试策略见 13-testing-strategy.md。

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.4 271 10/25/2026
2.1.3 99 10/25/2026
2.1.2 239 10/22/2026
2.1.1 112 10/21/2026
2.1.0 306 10/15/2026
2.0.9 430 10/9/2026
2.0.8 457 10/3/2026
2.0.7 101 10/2/2026
2.0.6 249 9/28/2026
2.0.5 356 9/23/2026
2.0.4 752 9/11/2026
2.0.3 105 9/11/2026
2.0.2 549 9/2/2026
2.0.1 108 9/2/2026
2.0.0 140 8/31/2026
1.5.1 123 8/29/2026
1.5.0 146 8/26/2026
1.4.0 151 8/21/2026
1.3.1 104 8/21/2026
1.3.0 115 8/21/2026
Loading failed