Rig.TUnit.Databases.NoSql.Cassandra
0.1.0-beta.2
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
<PackageReference Include="Rig.TUnit.Databases.NoSql.Cassandra" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Databases.NoSql.Cassandra" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Databases.NoSql.Cassandra" />
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"
#:package Rig.TUnit.Databases.NoSql.Cassandra@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Databases.NoSql.Cassandra&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Databases.NoSql.Cassandra&version=0.1.0-beta.2&prerelease
Rig.TUnit.Databases.NoSql.Cassandra
Testcontainers-backed Apache Cassandra fixture with
KeyspacePerTestHelperfor 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)
CassandraCSharpDriver3.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.CassandraFixtureRig.TUnit.Databases.NoSql.Cassandra.Options.CassandraFixtureOptionsRig.TUnit.Databases.NoSql.Cassandra.Builder.CassandraRigBuilderRig.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 defaultsystem; either callUSE {keyspace}or fully qualify table names.Unable to connect to any servers— the container is still warming up. Fixture waits forSELECT release_version FROM system.localbut under heavy parallel startup the wait may time out; raiseStartupTimeoutSeconds.
See docs/troubleshooting.md#cassandra.
Provider quirks + edge cases
- Cassandra is eventually consistent by default (
ONEconsistency level). Tests asserting after a write must useCL.LOCAL_QUORUMor poll; never assume read-your-writes. - Identifiers are lowercased unless quoted — but the quote form is not
safe against SQL injection, which is why
KeyspacePerTestHelperenforces the strict whitelist instead of quoting.
Benchmarks
See CassandraKeyspaceBenchmarks.cs;
baseline in benchmarks/baseline-005.json.
Related docs
License
MIT. See LICENSE.
| 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. |
-
net10.0
- Bogus (>= 35.6.1)
- CassandraCSharpDriver (>= 3.22.0)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Rig.TUnit.Databases.NoSql (>= 0.1.0-beta.2)
- Testcontainers (>= 4.11.0)
- Testcontainers.Cassandra (>= 4.11.0)
- TUnit.Core (>= 1.34.5)
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 |