Rig.TUnit.Concurrency 0.1.0-beta.2

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

Rig.TUnit.Concurrency

Concurrency + idempotency helpers: ConcurrencyAssert.TwoWriters, Precondition.IfMatchFails/NotModified, SequenceIdempotencyChecker.

What this package is

A small toolbox for the three most common concurrency-test shapes:

  1. Two-writers-one-wins (optimistic concurrency) — parameterised on the exception type so the same assertion works against EF Core's DbUpdateConcurrencyException, Mongo's MongoWriteException, Cosmos's 412 Precondition Failed, etc.
  2. HTTP ETag / If-Match — verify 412 on stale precondition and 304 on fresh one.
  3. Sequence idempotency — verify replaying the same sequence produces identical outcomes.

No containers, no dependencies beyond Rig.TUnit.Core — pure harness code.

When to use it

  • Testing optimistic-concurrency writes across heterogeneous stores.
  • Verifying HTTP cache-control semantics end-to-end.
  • Regression-guarding event-replay idempotency.
  • Not for: unit-testing lock contention — use Rig.TUnit.Parallelism.ParallelIsolationContract for that.

Prerequisites

  • .NET 10 SDK.

Quick start

using Rig.TUnit.Concurrency;
using Microsoft.EntityFrameworkCore;

await ConcurrencyAssert.TwoWriters(order)
    .OneWinsWith<DbUpdateConcurrencyException>(
        a => a.TryUpdateAsync(newValue: 1),
        b => b.TryUpdateAsync(newValue: 2));

Options

Property Type Default Description
TimeoutPerBranch TimeSpan 10s Per-writer deadline in TwoWriters
ExpectedLosers int 1 How many branches should raise the concurrency exception
PollingInterval TimeSpan 50ms Back-off for async sequence checks

Fixture + helper APIs

  • Rig.TUnit.Concurrency.ConcurrencyAssert
  • Rig.TUnit.Concurrency.Precondition
  • Rig.TUnit.Concurrency.SequenceIdempotencyChecker

Per-test isolation

All helpers are stateless — every call constructs its own harness. Safe under full parallelism.

Parallelism + performance

  • TwoWriters dispatches two Tasks and observes which throws.
  • Overhead: ~0.5 ms per assertion plus the cost of the writes.
  • Safe under full parallelism.

Troubleshooting

  • Both writers succeed — your store does not enforce optimistic concurrency at the row/document level. Fix the schema (add concurrency token / ETag) before re-running.
  • TimeoutPerBranch exceeded — one writer blocked indefinitely; likely a missing cancellation propagation in the code under test.

See docs/troubleshooting.md#concurrency.

Provider quirks + edge cases

  • OneWinsWith<TException> catches the first matching exception type from either branch; if your store wraps the underlying exception, match the outermost type or use a base class.
  • Precondition.IfMatchFails expects HTTP status 412; some gateways translate to 409 — pass expectedStatus: HttpStatusCode.Conflict to override.

Benchmarks

See ConcurrencyBenchmarks.cs; baseline in benchmarks/baseline-005.json.

License

MIT. See LICENSE.

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 (1)

Showing the top 1 NuGet packages that depend on Rig.TUnit.Concurrency:

Package Downloads
Rig.TUnit.All

Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-beta.2 54 4/27/2026
0.0.0-alpha.0.14 58 4/26/2026