-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Andre Hofmeister <[email protected]>
- Loading branch information
1 parent
e713c6f
commit 69292d1
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Neo4j | ||
|
||
[Neo4j](https://neo4j.com/product/neo4j-graph-database/) is a graph database designed to work with nodes and edges. It is a ACID-compliant transactional graph database engine, and developers can communicate with it using the HTTP endpoint or by using the **Bolt** protocol. | ||
|
||
The following example uses the following NuGet packages: | ||
|
||
```console title="Install the NuGet dependencies" | ||
dotnet add package Testcontainers.Neo4j | ||
dotnet add package Neo4j.Driver | ||
dotnet add package xunit | ||
``` | ||
|
||
IDEs and editors may also require the following packages to run tests: `xunit.runner.visualstudio` and `Microsoft.NET.Test.Sdk`. | ||
|
||
Copy and paste the following code into a new `.cs` test file within an existing test project. | ||
|
||
```csharp | ||
using Neo4j.Driver; | ||
using Testcontainers.Neo4j; | ||
using Xunit; | ||
|
||
namespace TestcontainersModules; | ||
|
||
public class Neo4jContainerTest : IAsyncLifetime | ||
{ | ||
private readonly Neo4jContainer neo4jContainer | ||
= new Neo4jBuilder() | ||
.Build(); | ||
|
||
[Fact] | ||
public async Task CanReadNeo4jDatabase() | ||
{ | ||
const string database = "neo4j"; | ||
|
||
await using var client = GraphDatabase.Driver(neo4jContainer.GetConnectionString()); | ||
|
||
await using var session = client.AsyncSession(cfg => cfg.WithDatabase(database)); | ||
|
||
Assert.Equal(database, session.SessionConfig.Database); | ||
} | ||
|
||
public Task InitializeAsync() | ||
=> neo4jContainer.StartAsync(); | ||
|
||
public Task DisposeAsync() | ||
=> neo4jContainer.DisposeAsync().AsTask(); | ||
} | ||
``` | ||
|
||
To execute the tests, use the command `dotnet test` from a terminal. | ||
|
||
[xunit]: https://xunit.net/ |