From aba9f75020bcd7f309e905fe71c874a765919eef Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Wed, 19 Oct 2022 15:55:42 +0200 Subject: [PATCH] test: Cover Neo4j and Cosmos DB database and password configuration properties --- .../Databases/AzuriteTestcontainerTest.cs | 8 ++++---- .../Databases/CosmosDbTestcontainerTest.cs | 10 +++++++++- .../Modules/Databases/Neo4jTestcontainerTest.cs | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/AzuriteTestcontainerTest.cs b/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/AzuriteTestcontainerTest.cs index 5c61ed3ae..5367c5d16 100644 --- a/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/AzuriteTestcontainerTest.cs +++ b/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/AzuriteTestcontainerTest.cs @@ -76,7 +76,7 @@ private AllServicesEnabled(AzuriteFixture.AzuriteWithCustomContainerPortsFixture } [Fact] - public async Task ShouldEstablishServiceConnection() + public async Task ConnectionEstablished() { var exception = await Record.ExceptionAsync(() => Task.WhenAll(EstablishConnection(this.commonContainerPorts), EstablishConnection(this.customContainerPorts))) .ConfigureAwait(false); @@ -131,7 +131,7 @@ public BlobServiceEnabled(AzuriteFixture.AzuriteWithBlobOnlyFixture azurite) } [Fact] - public async Task ShouldEstablishServiceConnection() + public async Task ConnectionEstablished() { // Given var blobServiceClient = new BlobServiceClient(this.azurite.Container.ConnectionString); @@ -174,7 +174,7 @@ public QueueServiceEnabled(AzuriteFixture.AzuriteWithQueueOnlyFixture azurite) } [Fact] - public async Task ShouldEstablishServiceConnection() + public async Task ConnectionEstablished() { // Given var blobServiceClient = new BlobServiceClient(this.azurite.Container.ConnectionString); @@ -217,7 +217,7 @@ public TableServiceEnabled(AzuriteFixture.AzuriteWithTableOnlyFixture azurite) } [Fact] - public async Task ShouldEstablishServiceConnection() + public async Task ConnectionEstablished() { // Given var blobServiceClient = new BlobServiceClient(this.azurite.Container.ConnectionString); diff --git a/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/CosmosDbTestcontainerTest.cs b/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/CosmosDbTestcontainerTest.cs index f5c708376..e6697eccd 100644 --- a/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/CosmosDbTestcontainerTest.cs +++ b/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/CosmosDbTestcontainerTest.cs @@ -4,6 +4,7 @@ namespace DotNet.Testcontainers.Tests.Unit using System.Net; using System.Net.Http; using System.Threading.Tasks; + using DotNet.Testcontainers.Configurations; using DotNet.Testcontainers.Tests.Fixtures; using Microsoft.Azure.Cosmos; using Xunit; @@ -37,7 +38,7 @@ private ConnectionTests(HttpClient httpClient, string connectionString) #pragma warning disable xUnit1004 [Fact(Skip = SkipReason)] - public async Task ShouldEstablishConnection() + public async Task ConnectionEstablished() { var accountProperties = await this.cosmosClient.ReadAccountAsync() .ConfigureAwait(false); @@ -54,6 +55,13 @@ public async Task CreateDatabaseTest() Assert.Equal(HttpStatusCode.Created, databaseResponse.StatusCode); } + [Fact(Skip = SkipReason)] + public void CannotSetPassword() + { + var cosmosDb = new CosmosDbTestcontainerConfiguration(); + Assert.Throws(() => cosmosDb.Password = string.Empty); + } + #pragma warning restore xUnit1004 public void Dispose() diff --git a/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/Neo4jTestcontainerTest.cs b/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/Neo4jTestcontainerTest.cs index 7e10ca02b..5ccdf5a4d 100644 --- a/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/Neo4jTestcontainerTest.cs +++ b/tests/Testcontainers.Tests/Unit/Containers/Unix/Modules/Databases/Neo4jTestcontainerTest.cs @@ -1,6 +1,8 @@ namespace DotNet.Testcontainers.Tests.Unit { + using System; using System.Threading.Tasks; + using DotNet.Testcontainers.Configurations; using DotNet.Testcontainers.Tests.Fixtures; using Xunit; @@ -22,5 +24,19 @@ public async Task ConnectionEstablished() Assert.Null(exception); } + + [Fact] + public void CannotSetDatabase() + { + var neo4j = new Neo4jTestcontainerConfiguration(); + Assert.Throws(() => neo4j.Database = string.Empty); + } + + [Fact] + public void CannotSetUsername() + { + var neo4j = new Neo4jTestcontainerConfiguration(); + Assert.Throws(() => neo4j.Username = string.Empty); + } } }