Sparkdo.Uow.Testing
3.0.0-preview.1
This is a prerelease version of Sparkdo.Uow.Testing.
dotnet add package Sparkdo.Uow.Testing --version 3.0.0-preview.1
NuGet\Install-Package Sparkdo.Uow.Testing -Version 3.0.0-preview.1
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="Sparkdo.Uow.Testing" Version="3.0.0-preview.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sparkdo.Uow.Testing" Version="3.0.0-preview.1" />
<PackageReference Include="Sparkdo.Uow.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 Sparkdo.Uow.Testing --version 3.0.0-preview.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sparkdo.Uow.Testing, 3.0.0-preview.1"
#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 Sparkdo.Uow.Testing@3.0.0-preview.1
#: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=Sparkdo.Uow.Testing&version=3.0.0-preview.1&prerelease
#tool nuget:?package=Sparkdo.Uow.Testing&version=3.0.0-preview.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sparkdo.Uow.Testing
工作单元测试工装。只记录与注错,不引断言库。
安装
dotnet add package Sparkdo.Uow.Testing
本包只引契约包;要跑真实管理器请同时引 Sparkdo.Uow。
用法
var resource = new TestFlushableResource
{
OnFlush = _ => new ValueTask<bool>(false),
OnCommit = _ => ValueTask.CompletedTask,
OnRollback = _ => ValueTask.CompletedTask,
OnDispose = () => ValueTask.CompletedTask,
};
var classifier = new StubClassifier(e => e is TimeoutException);
Calls按发生序记录flush/commit/rollback/dispose,每次读取返回快照,线程安全。- 注入的委托抛异常即模拟对应阶段失败;不注入就是空成功。
TestFlushableResource.OnFlush默认返回 false,即"没有待提交工作",一轮即收敛。IsDisposed在释放后为 true。StubClassifier.IsTransientPredicate可随时替换;为null时一律判非瞬态。TestResource可继承,protected void Record(string call)供自定义阶段插标签。
接进 DI
分类器在管理器构造时快照,注册必须写在 AddSparkdoUnitOfWork() 之前、容器建好之前:
services.AddSingleton<IFailureClassifier>(new StubClassifier(_ => true));
services.AddSparkdoUnitOfWork();
退避等待走注入的 TimeProvider,换 FakeTimeProvider 即可断言重试次数与延迟区间,
不必真等。
| 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. net11.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Sparkdo.Uow.Abstractions (>= 3.0.0-preview.1)
-
net11.0
- Sparkdo.Uow.Abstractions (>= 3.0.0-preview.1)
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 |
|---|---|---|
| 3.0.0-preview.1 | 67 | 10/30/2026 |