Sparkdo.UnitOfWork.Testing 2.0.0-preview.2

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

Sparkdo.UnitOfWork.Testing

Sparkdo.UnitOfWork.Testing 是工作单元的测试伴侣包。它只提供测试替身和集成契约探针,不进入生产运行时依赖图,也不提供数据库、事务或 Entity Framework Core 实现。

快速开始

using Sparkdo.UnitOfWork.Integration;
using Sparkdo.UnitOfWork.Testing;

var handler = new RecordingUnitOfWorkCompletionHandler();
var enlistment = new UnitOfWorkEnlistmentProbe();
enlistment.Enlist(handler);

var results = await enlistment.CompleteEnlistedAsync();
if (results.Count != 1 || !results[0].IsCompleted)
{
    throw new InvalidOperationException("工作单元完成探针未通过。");
}

能力边界

类型 用途
UnitOfWorkTestKit 围绕真实 IUnitOfWorkManager 执行成功、回滚和异常路径,减少测试样板。
RecordingUnitOfWorkCompletionHandler 记录完成与回滚调用,并可注入确定的完成结果。
RecordingUnitOfWorkObserver 记录运行时发布的 UnitOfWorkOutcome,用于观察契约验证。
UnitOfWorkEnlistmentProbe 以显式顺序驱动已登记的完成处理器,验证 provider 集成协议。

测试替身不替代运行时实现。生产项目只应引用 Sparkdo.UnitOfWork.Abstractions 和所需的运行时或基础设施集成包。

Product 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.

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.0.0-preview.2 40 7/20/2026
2.0.0-preview.1 46 7/18/2026