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

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

Rig.TUnit.Databases.NoSql.Cassandra

Testcontainers-backed Apache Cassandra fixture with KeyspacePerTestHelper for injection-safe per-test keyspaces.

What this package is

The Rig.TUnit Cassandra provider. CassandraFixture spins Apache Cassandra via Testcontainers and exposes a Session ready for CQL. KeyspacePerTestHelper is the novel piece — it validates keyspace names via a CQL-identifier whitelist (48-char cap, [a-z_][a-z0-9_]* alphabet, no " injection possible) and issues CREATE KEYSPACE / DROP KEYSPACE per test inside an IAsyncDisposable scope.

When to use it

  • Integration tests hitting a real Cassandra cluster (single-node dev replica is sufficient for most cases).
  • Verifying CQL against the server's actual parser (string comparison of CQL against the driver's parser is not enough).
  • Not for: unit tests — the startup cost is significant.

Prerequisites

  • .NET 10 SDK
  • Docker Desktop / Colima (first pull ~600 MB)
  • CassandraCSharpDriver 3.x (transitive)

Quick start

using Cassandra;
using Rig.TUnit.Core.Helpers;
using Rig.TUnit.Databases.NoSql.Cassandra.Fixtures;
using Rig.TUnit.Databases.NoSql.Cassandra.Helpers;

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

var key = IsolationKey.FromExecutionContext();
await using var scope = await KeyspacePerTestHelper.CreateAsync(
    fx.Session, key, prefix: "orders");

Options

Property Type Default Description
Image string "cassandra:5.0" Container image
StartupTimeoutSeconds int 180 Cassandra boot is slow
ReplicationStrategy string "SimpleStrategy" Keyspace default
ReplicationFactor int 1 For single-node test cluster

Fixture + helper APIs

  • Rig.TUnit.Databases.NoSql.Cassandra.Fixtures.CassandraFixture
  • Rig.TUnit.Databases.NoSql.Cassandra.Options.CassandraFixtureOptions
  • Rig.TUnit.Databases.NoSql.Cassandra.Builder.CassandraRigBuilder
  • Rig.TUnit.Databases.NoSql.Cassandra.Helpers.KeyspacePerTestHelper

Per-test isolation

KeyspacePerTestHelper.CreateAsync(session, isolationKey, prefix) returns an IAsyncDisposable scope owning a keyspace named {prefix}_{IsolationKey:short}. BuildSafeKeyspace enforces the CQL identifier whitelist (no ", ;, --, whitespace; 48-char cap; lowercase start; underscore-alphanumeric continuations). On dispose: DROP KEYSPACE.

Parallelism + performance

  • First-run pull: ~30 s.
  • Warm startup: ~45–90 s (Cassandra is slow to boot).
  • Per-test keyspace create + drop: ~300 ms.
  • Parallelism: 4–8 tests concurrently is typical; each keyspace is isolated so contention is minimal.

Troubleshooting

  • Unconfigured table — the session's keyspace is still the default system; either call USE {keyspace} or fully qualify table names.
  • Unable to connect to any servers — the container is still warming up. Fixture waits for SELECT release_version FROM system.local but under heavy parallel startup the wait may time out; raise StartupTimeoutSeconds.

See docs/troubleshooting.md#cassandra.

Provider quirks + edge cases

  • Cassandra is eventually consistent by default (ONE consistency level). Tests asserting after a write must use CL.LOCAL_QUORUM or poll; never assume read-your-writes.
  • Identifiers are lowercased unless quoted — but the quote form is not safe against SQL injection, which is why KeyspacePerTestHelper enforces the strict whitelist instead of quoting.

Benchmarks

See CassandraKeyspaceBenchmarks.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.Databases.NoSql.Cassandra:

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