Skip to content

Commit e80cbe3

Browse files
committed
Add cassandra.md to documentation.
1 parent b53e4f2 commit e80cbe3

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

docs/modules/cassandra.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Cassandra
2+
3+
[Cassandra](https://cassandra.apache.org/) is a powerful, open-source NoSQL distributed, highly available, fault-tolerant database used to store, manage, and retrieve structured data.
4+
5+
Add the following dependency to your project file:
6+
7+
```shell title="NuGet"
8+
dotnet add package Testcontainers.Cassandra
9+
```
10+
11+
You can start a Cassandra container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method.
12+
13+
=== "Usage Example"
14+
```csharp
15+
--8<-- "tests/Testcontainers.Cassandra.Tests/CassandraContainerTest.cs:UseCassandraContainer"
16+
```
17+
18+
The test example uses the following NuGet dependencies:
19+
20+
=== "Package References"
21+
```xml
22+
--8<-- "tests/Testcontainers.Cassandra.Tests/Testcontainers.Cassandra.Tests.csproj:PackageReferences"
23+
```
24+
25+
To execute the tests, use the command `dotnet test` from a terminal.
26+
27+
--8<-- "docs/modules/_call_out_test_projects.txt"

tests/Testcontainers.Cassandra.Tests/CassandraContainerTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace Testcontainers.Cassandra;
22

33
public sealed class CassandraContainerTest : IAsyncLifetime
44
{
5+
// # --8<-- [start:UseCassandraContainer]
56
private readonly CassandraContainer _cassandraContainer = new CassandraBuilder().Build();
67

78
public Task InitializeAsync()
@@ -50,6 +51,7 @@ public void ExecuteCqlStatementReturnsExpectedResult()
5051
Assert.Single(rows);
5152
Assert.Equal("COMPLETED", rows[0]["bootstrapped"]);
5253
}
54+
// # --8<-- [end:UseCassandraContainer]
5355

5456
[Fact]
5557
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
@@ -66,4 +68,4 @@ public async Task ExecScriptAsyncReturnsSuccess()
6668
Assert.True(0L.Equals(execResult.ExitCode), execResult.Stderr);
6769
Assert.Empty(execResult.Stderr);
6870
}
69-
}
71+
}

tests/Testcontainers.Cassandra.Tests/Testcontainers.Cassandra.Tests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
<IsPublishable>false</IsPublishable>
66
</PropertyGroup>
77
<ItemGroup>
8+
<!-- -8<- [start:PackageReferences] -->
89
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
910
<PackageReference Include="coverlet.collector"/>
1011
<PackageReference Include="xunit.runner.visualstudio"/>
1112
<PackageReference Include="xunit"/>
1213
<PackageReference Include="CassandraCSharpDriver"/>
14+
<!-- -8<- [end:PackageReferences] -->
1315
</ItemGroup>
1416
<ItemGroup>
1517
<ProjectReference Include="../../src/Testcontainers.Cassandra/Testcontainers.Cassandra.csproj"/>
1618
<ProjectReference Include="../Testcontainers.Commons/Testcontainers.Commons.csproj"/>
1719
</ItemGroup>
18-
</Project>
20+
</Project>

0 commit comments

Comments
 (0)