Rig.TUnit.Databases.NoSql.Cosmos 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.Databases.NoSql.Cosmos.
dotnet add package Rig.TUnit.Databases.NoSql.Cosmos --version 0.1.0-beta.2
                    
NuGet\Install-Package Rig.TUnit.Databases.NoSql.Cosmos -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.Databases.NoSql.Cosmos" 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.Databases.NoSql.Cosmos" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.Databases.NoSql.Cosmos" />
                    
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.Databases.NoSql.Cosmos --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.Databases.NoSql.Cosmos, 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.Databases.NoSql.Cosmos@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.Databases.NoSql.Cosmos&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.Databases.NoSql.Cosmos&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

Rig.TUnit.Databases.NoSql.Cosmos

Testcontainers-backed Linux Cosmos emulator fixture with RuChargeCapture and PartitionKeyDistributionChecker.

What this package is

The Rig.TUnit Cosmos DB provider. CosmosFixture spins the mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview Linux emulator via the generic Testcontainers API (the dedicated Testcontainers.CosmosDb module targets the legacy Windows emulator — incompatible, see testcontainers-dotnet#1306). Ships two novel helpers: RuChargeCapture (per-operation RU budget assertions) and PartitionKeyDistributionChecker (max-share + normalised Shannon entropy hot-partition detector).

When to use it

  • Integration tests against the Cosmos API surface.
  • Asserting per-operation RU budgets stay within design targets.
  • Detecting hot-partition drift before production.
  • Not for: Windows CI runners — the Linux emulator cannot host there. Tests marked [Category("cosmos")] auto-skip via runtime OperatingSystem.IsWindows() guard.

Prerequisites

  • .NET 10 SDK
  • Docker Desktop / Colima (Linux containers only)
  • Microsoft.Azure.Cosmos 3.x (transitive)

Quick start

using Microsoft.Azure.Cosmos;
using Rig.TUnit.Databases.NoSql.Cosmos.Fixtures;
using Rig.TUnit.Databases.NoSql.Cosmos.Helpers;

await using var fx = new CosmosFixture();
await fx.InitializeAsync();

using var client = new CosmosClient(fx.ConnectionString);
var db = await client.CreateDatabaseIfNotExistsAsync(fx.DatabaseName);

Options

Property Type Default Description
Image string "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview" Emulator image
StartupTimeoutSeconds int 300 Emulator boot is slow
DatabaseName string "rigtunit" Default database
HttpsGatewayPort int 8081 Emulator gateway port

Fixture + helper APIs

  • Rig.TUnit.Databases.NoSql.Cosmos.Fixtures.CosmosFixture
  • Rig.TUnit.Databases.NoSql.Cosmos.Options.CosmosFixtureOptions
  • Rig.TUnit.Databases.NoSql.Cosmos.Builder.CosmosRigBuilder
  • Rig.TUnit.Databases.NoSql.Cosmos.Helpers.RuChargeCapture
  • Rig.TUnit.Databases.NoSql.Cosmos.Helpers.PartitionKeyDistributionChecker

Per-test isolation

Container-per-test (IsolationKey suffix) is cost-prohibitive — the emulator takes ~2 min to start. Default is one fixture per test-class with per-test container names (test-cosmos-{IsolationKey}) created via CreateContainerIfNotExistsAsync and deleted on teardown.

Parallelism + performance

  • First-run pull: ~2–3 min (~3 GB image).
  • Warm startup: ~90–120 s.
  • Per-test container create + delete: ~200 ms + RU cost.
  • Parallelism: Linux-only, typically 2–4 concurrent tests; emulator does not like high churn.

Troubleshooting

  • Tests skipped on Windows CI — expected; Cosmos tests gate on OperatingSystem.IsWindows() returning false. Run the matrix cell on Linux runners.
  • TransportException — emulator still warming up; fixture waits but in a busy CI cell the default timeout can be exceeded. Raise StartupTimeoutSeconds.
  • RU budget assertions flake — Cosmos RU charges drift with index policy and data shape; capture a baseline per-operation first, then assert within a 15 % tolerance.

See docs/troubleshooting.md#cosmos.

Provider quirks + edge cases

  • Emulator uses a self-signed certificate; the fixture disables cert validation on the embedded HttpClient. Do not reuse that handler in production.
  • RuChargeCapture is thread-safe; aggregate RU budgets across parallel ops with capture.Total.
  • PartitionKeyDistributionChecker.IsBalanced(keys, threshold) uses normalised entropy; the default threshold is 0.9 (0=maximally skewed, 1=uniform).

Benchmarks

See CosmosBenchmarks.cs; baseline in benchmarks/baseline-005.json. RU-charge assertions are a common regression vector and are tracked closely.

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.Databases.NoSql.Cosmos:

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 45 4/27/2026
0.0.0-alpha.0.14 48 4/26/2026