diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index db97a7309..1c5d05cc5 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -13,7 +13,7 @@
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": true
},
- "ghcr.io/devcontainers/features/dotnet:2.4.1": {
+ "ghcr.io/devcontainers/features/dotnet:2.4.2": {
"version": "10.0",
"installUsingApt": false
}
diff --git a/src/Testcontainers.ActiveMq/ActiveMqConnectionStringProvider.cs b/src/Testcontainers.ActiveMq/ActiveMqConnectionStringProvider.cs
new file mode 100644
index 000000000..e470e5af9
--- /dev/null
+++ b/src/Testcontainers.ActiveMq/ActiveMqConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.ActiveMq;
+
+///
+/// Provides the ActiveMq connection string.
+///
+internal sealed class ActiveMqConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBrokerAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.ActiveMq/ArtemisBuilder.cs b/src/Testcontainers.ActiveMq/ArtemisBuilder.cs
index fcbbed35d..2c561456d 100644
--- a/src/Testcontainers.ActiveMq/ArtemisBuilder.cs
+++ b/src/Testcontainers.ActiveMq/ArtemisBuilder.cs
@@ -106,6 +106,7 @@ protected override ArtemisBuilder Init()
.WithPortBinding(ArtemisConsolePort, true)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new ActiveMqConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("HTTP Server started"));
}
diff --git a/src/Testcontainers.ArangoDb/ArangoDbBuilder.cs b/src/Testcontainers.ArangoDb/ArangoDbBuilder.cs
index b09460867..9a0327bdb 100644
--- a/src/Testcontainers.ArangoDb/ArangoDbBuilder.cs
+++ b/src/Testcontainers.ArangoDb/ArangoDbBuilder.cs
@@ -91,6 +91,7 @@ protected override ArangoDbBuilder Init()
return base.Init()
.WithPortBinding(ArangoDbPort, true)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new ArangoDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Have fun!"));
}
diff --git a/src/Testcontainers.ArangoDb/ArangoDbConnectionStringProvider.cs b/src/Testcontainers.ArangoDb/ArangoDbConnectionStringProvider.cs
new file mode 100644
index 000000000..6ca7cb0c2
--- /dev/null
+++ b/src/Testcontainers.ArangoDb/ArangoDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.ArangoDb;
+
+///
+/// Provides the ArangoDb connection string.
+///
+internal sealed class ArangoDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetTransportAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Azurite/AzuriteBuilder.cs b/src/Testcontainers.Azurite/AzuriteBuilder.cs
index d85992e6d..783612058 100644
--- a/src/Testcontainers.Azurite/AzuriteBuilder.cs
+++ b/src/Testcontainers.Azurite/AzuriteBuilder.cs
@@ -132,7 +132,8 @@ protected override AzuriteBuilder Init()
.WithPortBinding(QueuePort, true)
.WithPortBinding(TablePort, true)
.WithEntrypoint("azurite")
- .WithCommand("--blobHost", "0.0.0.0", "--queueHost", "0.0.0.0", "--tableHost", "0.0.0.0");
+ .WithCommand("--blobHost", "0.0.0.0", "--queueHost", "0.0.0.0", "--tableHost", "0.0.0.0")
+ .WithConnectionStringProvider(new AzuriteConnectionStringProvider());
}
///
diff --git a/src/Testcontainers.Azurite/AzuriteConnectionStringProvider.cs b/src/Testcontainers.Azurite/AzuriteConnectionStringProvider.cs
new file mode 100644
index 000000000..02ddce9b1
--- /dev/null
+++ b/src/Testcontainers.Azurite/AzuriteConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Azurite;
+
+///
+/// Provides the Azurite connection string.
+///
+internal sealed class AzuriteConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.BigQuery/BigQueryBuilder.cs b/src/Testcontainers.BigQuery/BigQueryBuilder.cs
index 3b54b898e..a34d600a2 100644
--- a/src/Testcontainers.BigQuery/BigQueryBuilder.cs
+++ b/src/Testcontainers.BigQuery/BigQueryBuilder.cs
@@ -88,6 +88,7 @@ protected override BigQueryBuilder Init()
return base.Init()
.WithPortBinding(BigQueryPort, true)
.WithProject(DefaultProjectId)
+ .WithConnectionStringProvider(new BigQueryConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("(?s).*listening.*$"));
}
diff --git a/src/Testcontainers.BigQuery/BigQueryConnectionStringProvider.cs b/src/Testcontainers.BigQuery/BigQueryConnectionStringProvider.cs
new file mode 100644
index 000000000..0235318b5
--- /dev/null
+++ b/src/Testcontainers.BigQuery/BigQueryConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.BigQuery;
+
+///
+/// Provides the BigQuery connection string.
+///
+internal sealed class BigQueryConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetEmulatorEndpoint();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Bigtable/BigtableBuilder.cs b/src/Testcontainers.Bigtable/BigtableBuilder.cs
index 063499928..5818d209c 100644
--- a/src/Testcontainers.Bigtable/BigtableBuilder.cs
+++ b/src/Testcontainers.Bigtable/BigtableBuilder.cs
@@ -77,6 +77,7 @@ protected override BigtableBuilder Init()
.WithPortBinding(BigtablePort, true)
.WithEntrypoint("gcloud")
.WithCommand("beta", "emulators", "bigtable", "start", "--host-port", "0.0.0.0:" + BigtablePort)
+ .WithConnectionStringProvider(new BigtableConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("(?s).*running.*$"));
}
diff --git a/src/Testcontainers.Bigtable/BigtableConnectionStringProvider.cs b/src/Testcontainers.Bigtable/BigtableConnectionStringProvider.cs
new file mode 100644
index 000000000..740ca6ff7
--- /dev/null
+++ b/src/Testcontainers.Bigtable/BigtableConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Bigtable;
+
+///
+/// Provides the Bigtable connection string.
+///
+internal sealed class BigtableConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetEmulatorEndpoint();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Cassandra/CassandraBuilder.cs b/src/Testcontainers.Cassandra/CassandraBuilder.cs
index b60b195b6..f6f9e87d2 100644
--- a/src/Testcontainers.Cassandra/CassandraBuilder.cs
+++ b/src/Testcontainers.Cassandra/CassandraBuilder.cs
@@ -83,6 +83,7 @@ protected override CassandraBuilder Init()
.WithEnvironment("CASSANDRA_SNITCH", "GossipingPropertyFileSnitch")
.WithEnvironment("CASSANDRA_ENDPOINT_SNITCH", "GossipingPropertyFileSnitch")
.WithEnvironment("CASSANDRA_DC", DefaultDatacenterName)
+ .WithConnectionStringProvider(new CassandraConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Startup complete"));
}
diff --git a/src/Testcontainers.Cassandra/CassandraConnectionStringProvider.cs b/src/Testcontainers.Cassandra/CassandraConnectionStringProvider.cs
new file mode 100644
index 000000000..ce6fa7280
--- /dev/null
+++ b/src/Testcontainers.Cassandra/CassandraConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Cassandra;
+
+///
+/// Provides the Cassandra connection string.
+///
+internal sealed class CassandraConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.ClickHouse/ClickHouseBuilder.cs b/src/Testcontainers.ClickHouse/ClickHouseBuilder.cs
index d09a1409a..78d82fbd7 100644
--- a/src/Testcontainers.ClickHouse/ClickHouseBuilder.cs
+++ b/src/Testcontainers.ClickHouse/ClickHouseBuilder.cs
@@ -120,6 +120,7 @@ protected override ClickHouseBuilder Init()
.WithDatabase(DefaultDatabase)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new ClickHouseConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPort(HttpPort).ForResponseMessageMatching(IsNodeReadyAsync)));
}
diff --git a/src/Testcontainers.ClickHouse/ClickHouseConnectionStringProvider.cs b/src/Testcontainers.ClickHouse/ClickHouseConnectionStringProvider.cs
new file mode 100644
index 000000000..26e084822
--- /dev/null
+++ b/src/Testcontainers.ClickHouse/ClickHouseConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.ClickHouse;
+
+///
+/// Provides the ClickHouse connection string.
+///
+internal sealed class ClickHouseConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.CockroachDb/CockroachDbBuilder.cs b/src/Testcontainers.CockroachDb/CockroachDbBuilder.cs
index a665dbfef..265dbebdb 100644
--- a/src/Testcontainers.CockroachDb/CockroachDbBuilder.cs
+++ b/src/Testcontainers.CockroachDb/CockroachDbBuilder.cs
@@ -122,6 +122,7 @@ protected override CockroachDbBuilder Init()
.WithPassword(DefaultPassword)
.WithCommand("start-single-node")
.WithCommand("--insecure")
+ .WithConnectionStringProvider(new CockroachDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPort(CockroachDbRestPort).ForPath("/health")));
}
diff --git a/src/Testcontainers.CockroachDb/CockroachDbConnectionStringProvider.cs b/src/Testcontainers.CockroachDb/CockroachDbConnectionStringProvider.cs
new file mode 100644
index 000000000..32f0c1c79
--- /dev/null
+++ b/src/Testcontainers.CockroachDb/CockroachDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.CockroachDb;
+
+///
+/// Provides the CockroachDb connection string.
+///
+internal sealed class CockroachDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Consul/ConsulBuilder.cs b/src/Testcontainers.Consul/ConsulBuilder.cs
index 907d362fa..8b9e69fce 100644
--- a/src/Testcontainers.Consul/ConsulBuilder.cs
+++ b/src/Testcontainers.Consul/ConsulBuilder.cs
@@ -80,6 +80,7 @@ protected override ConsulBuilder Init()
.WithPortBinding(ConsulGrpcPort, true)
.WithCommand("agent", "-dev", "-client", "0.0.0.0")
.WithCreateParameterModifier(cmd => cmd.HostConfig.CapAdd = new[] { "IPC_LOCK" })
+ .WithConnectionStringProvider(new ConsulConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/v1/status/leader").ForPort(ConsulHttpPort)));
}
diff --git a/src/Testcontainers.Consul/ConsulConnectionStringProvider.cs b/src/Testcontainers.Consul/ConsulConnectionStringProvider.cs
new file mode 100644
index 000000000..5c7209ce7
--- /dev/null
+++ b/src/Testcontainers.Consul/ConsulConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Consul;
+
+///
+/// Provides the Consul connection string.
+///
+internal sealed class ConsulConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs b/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs
index 15c90d323..e7bbba9fd 100644
--- a/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs
+++ b/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs
@@ -77,6 +77,7 @@ protected override CosmosDbBuilder Init()
{
return base.Init()
.WithPortBinding(CosmosDbPort, true)
+ .WithConnectionStringProvider(new CosmosDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new WaitUntil()));
}
diff --git a/src/Testcontainers.CosmosDb/CosmosDbConnectionStringProvider.cs b/src/Testcontainers.CosmosDb/CosmosDbConnectionStringProvider.cs
new file mode 100644
index 000000000..e000734dd
--- /dev/null
+++ b/src/Testcontainers.CosmosDb/CosmosDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.CosmosDb;
+
+///
+/// Provides the CosmosDb connection string.
+///
+internal sealed class CosmosDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.CouchDb/CouchDbBuilder.cs b/src/Testcontainers.CouchDb/CouchDbBuilder.cs
index bc70c6b5a..c8ba4a8c1 100644
--- a/src/Testcontainers.CouchDb/CouchDbBuilder.cs
+++ b/src/Testcontainers.CouchDb/CouchDbBuilder.cs
@@ -103,6 +103,7 @@ protected override CouchDbBuilder Init()
.WithPortBinding(CouchDbPort, true)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new CouchDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/").ForPort(CouchDbPort)));
}
diff --git a/src/Testcontainers.CouchDb/CouchDbConnectionStringProvider.cs b/src/Testcontainers.CouchDb/CouchDbConnectionStringProvider.cs
new file mode 100644
index 000000000..1d60ab04d
--- /dev/null
+++ b/src/Testcontainers.CouchDb/CouchDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.CouchDb;
+
+///
+/// Provides the CouchDb connection string.
+///
+internal sealed class CouchDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Couchbase/CouchbaseBuilder.cs b/src/Testcontainers.Couchbase/CouchbaseBuilder.cs
index 856eabbb9..e0a44a123 100644
--- a/src/Testcontainers.Couchbase/CouchbaseBuilder.cs
+++ b/src/Testcontainers.Couchbase/CouchbaseBuilder.cs
@@ -175,6 +175,7 @@ protected override CouchbaseBuilder Init()
.WithPortBinding(KvPort, true)
.WithPortBinding(KvSslPort, true)
.WithBucket(CouchbaseBucket.Default)
+ .WithConnectionStringProvider(new CouchbaseConnectionStringProvider())
.WithStartupCallback(ConfigureCouchbaseAsync);
}
diff --git a/src/Testcontainers.Couchbase/CouchbaseConnectionStringProvider.cs b/src/Testcontainers.Couchbase/CouchbaseConnectionStringProvider.cs
new file mode 100644
index 000000000..757e9013a
--- /dev/null
+++ b/src/Testcontainers.Couchbase/CouchbaseConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Couchbase;
+
+///
+/// Provides the Couchbase connection string.
+///
+internal sealed class CouchbaseConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Db2/Db2Builder.cs b/src/Testcontainers.Db2/Db2Builder.cs
index 9db99d4f9..bbf81ef25 100644
--- a/src/Testcontainers.Db2/Db2Builder.cs
+++ b/src/Testcontainers.Db2/Db2Builder.cs
@@ -139,6 +139,7 @@ protected override Db2Builder Init() => base.Init()
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
.WithPrivileged(true)
+ .WithConnectionStringProvider(new Db2ConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Setup has completed."));
///
diff --git a/src/Testcontainers.Db2/Db2ConnectionStringProvider.cs b/src/Testcontainers.Db2/Db2ConnectionStringProvider.cs
new file mode 100644
index 000000000..ff6105ad1
--- /dev/null
+++ b/src/Testcontainers.Db2/Db2ConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Db2;
+
+///
+/// Provides the Db2 connection string.
+///
+internal sealed class Db2ConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.DynamoDb/DynamoDbBuilder.cs b/src/Testcontainers.DynamoDb/DynamoDbBuilder.cs
index 46fa8290f..a808db53e 100644
--- a/src/Testcontainers.DynamoDb/DynamoDbBuilder.cs
+++ b/src/Testcontainers.DynamoDb/DynamoDbBuilder.cs
@@ -75,6 +75,7 @@ protected override DynamoDbBuilder Init()
{
return base.Init()
.WithPortBinding(DynamoDbPort, true)
+ .WithConnectionStringProvider(new DynamoDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/").ForPort(DynamoDbPort).ForStatusCode(HttpStatusCode.BadRequest)));
}
diff --git a/src/Testcontainers.DynamoDb/DynamoDbConnectionStringProvider.cs b/src/Testcontainers.DynamoDb/DynamoDbConnectionStringProvider.cs
new file mode 100644
index 000000000..7ed71ebac
--- /dev/null
+++ b/src/Testcontainers.DynamoDb/DynamoDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.DynamoDb;
+
+///
+/// Provides the DynamoDb connection string.
+///
+internal sealed class DynamoDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Elasticsearch/ElasticsearchBuilder.cs b/src/Testcontainers.Elasticsearch/ElasticsearchBuilder.cs
index ef89f949d..8bdac8897 100644
--- a/src/Testcontainers.Elasticsearch/ElasticsearchBuilder.cs
+++ b/src/Testcontainers.Elasticsearch/ElasticsearchBuilder.cs
@@ -107,7 +107,8 @@ protected override ElasticsearchBuilder Init()
.WithPassword(DefaultPassword)
.WithEnvironment("discovery.type", "single-node")
.WithEnvironment("ingest.geoip.downloader.enabled", "false")
- .WithResourceMapping(DefaultMemoryVmOption, ElasticsearchDefaultMemoryVmOptionFilePath);
+ .WithResourceMapping(DefaultMemoryVmOption, ElasticsearchDefaultMemoryVmOptionFilePath)
+ .WithConnectionStringProvider(new ElasticsearchConnectionStringProvider());
}
///
diff --git a/src/Testcontainers.Elasticsearch/ElasticsearchConnectionStringProvider.cs b/src/Testcontainers.Elasticsearch/ElasticsearchConnectionStringProvider.cs
new file mode 100644
index 000000000..d691e9e4f
--- /dev/null
+++ b/src/Testcontainers.Elasticsearch/ElasticsearchConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Elasticsearch;
+
+///
+/// Provides the Elasticsearch connection string.
+///
+internal sealed class ElasticsearchConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.EventHubs/EventHubsBuilder.cs b/src/Testcontainers.EventHubs/EventHubsBuilder.cs
index 0fce024f6..96177544f 100644
--- a/src/Testcontainers.EventHubs/EventHubsBuilder.cs
+++ b/src/Testcontainers.EventHubs/EventHubsBuilder.cs
@@ -168,6 +168,7 @@ protected override EventHubsBuilder Init()
return base.Init()
.WithPortBinding(EventHubsPort, true)
.WithPortBinding(EventHubsHttpPort, true)
+ .WithConnectionStringProvider(new EventHubsConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer()
// https://github.com/Azure/azure-event-hubs-emulator-installer/issues/69#issuecomment-3762895979.
.UntilMessageIsLogged("Emulator Service is Successfully Up!")
diff --git a/src/Testcontainers.EventHubs/EventHubsConnectionStringProvider.cs b/src/Testcontainers.EventHubs/EventHubsConnectionStringProvider.cs
new file mode 100644
index 000000000..586612d71
--- /dev/null
+++ b/src/Testcontainers.EventHubs/EventHubsConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.EventHubs;
+
+///
+/// Provides the Event Hubs connection string.
+///
+internal sealed class EventHubsConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.FakeGcsServer/FakeGcsServerBuilder.cs b/src/Testcontainers.FakeGcsServer/FakeGcsServerBuilder.cs
index d5a9252ac..2440ba24d 100644
--- a/src/Testcontainers.FakeGcsServer/FakeGcsServerBuilder.cs
+++ b/src/Testcontainers.FakeGcsServer/FakeGcsServerBuilder.cs
@@ -79,6 +79,7 @@ protected override FakeGcsServerBuilder Init()
.WithPortBinding(FakeGcsServerPort, true)
.WithEntrypoint("/bin/sh", "-c")
.WithCommand("while [ ! -f " + StartupScriptFilePath + " ]; do sleep 0.1; done; " + StartupScriptFilePath)
+ .WithConnectionStringProvider(new FakeGcsServerConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("server started"))
.WithStartupCallback((container, ct) =>
{
diff --git a/src/Testcontainers.FakeGcsServer/FakeGcsServerConnectionStringProvider.cs b/src/Testcontainers.FakeGcsServer/FakeGcsServerConnectionStringProvider.cs
new file mode 100644
index 000000000..55e55f1d1
--- /dev/null
+++ b/src/Testcontainers.FakeGcsServer/FakeGcsServerConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.FakeGcsServer;
+
+///
+/// Provides the FakeGcsServer connection string.
+///
+internal sealed class FakeGcsServerConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.FirebirdSql/FirebirdSqlBuilder.cs b/src/Testcontainers.FirebirdSql/FirebirdSqlBuilder.cs
index 36192a960..b05baf06c 100644
--- a/src/Testcontainers.FirebirdSql/FirebirdSqlBuilder.cs
+++ b/src/Testcontainers.FirebirdSql/FirebirdSqlBuilder.cs
@@ -121,6 +121,7 @@ protected override FirebirdSqlBuilder Init()
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
.WithResourceMapping(Encoding.Default.GetBytes(TestQueryString), "/home/firebird_check.sql")
+ .WithConnectionStringProvider(new FirebirdSqlConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilContainerIsHealthy());
}
diff --git a/src/Testcontainers.FirebirdSql/FirebirdSqlConnectionStringProvider.cs b/src/Testcontainers.FirebirdSql/FirebirdSqlConnectionStringProvider.cs
new file mode 100644
index 000000000..676170915
--- /dev/null
+++ b/src/Testcontainers.FirebirdSql/FirebirdSqlConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.FirebirdSql;
+
+///
+/// Provides the FirebirdSql connection string.
+///
+internal sealed class FirebirdSqlConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Firestore/FirestoreBuilder.cs b/src/Testcontainers.Firestore/FirestoreBuilder.cs
index da313809a..404d9e38c 100644
--- a/src/Testcontainers.Firestore/FirestoreBuilder.cs
+++ b/src/Testcontainers.Firestore/FirestoreBuilder.cs
@@ -77,6 +77,7 @@ protected override FirestoreBuilder Init()
.WithPortBinding(FirestorePort, true)
.WithEntrypoint("gcloud")
.WithCommand("beta", "emulators", "firestore", "start", "--host-port", "0.0.0.0:" + FirestorePort)
+ .WithConnectionStringProvider(new FirestoreConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("(?s).*running.*$"));
}
diff --git a/src/Testcontainers.Firestore/FirestoreConnectionStringProvider.cs b/src/Testcontainers.Firestore/FirestoreConnectionStringProvider.cs
new file mode 100644
index 000000000..d08e200ee
--- /dev/null
+++ b/src/Testcontainers.Firestore/FirestoreConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Firestore;
+
+///
+/// Provides the Firestore connection string.
+///
+internal sealed class FirestoreConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetEmulatorEndpoint();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Grafana/GrafanaBuilder.cs b/src/Testcontainers.Grafana/GrafanaBuilder.cs
index 62c772ea3..e478cb835 100644
--- a/src/Testcontainers.Grafana/GrafanaBuilder.cs
+++ b/src/Testcontainers.Grafana/GrafanaBuilder.cs
@@ -113,6 +113,7 @@ protected override GrafanaBuilder Init()
.WithPortBinding(GrafanaPort, true)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new GrafanaConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/api/health").ForPort(GrafanaPort)));
}
diff --git a/src/Testcontainers.Grafana/GrafanaConnectionStringProvider.cs b/src/Testcontainers.Grafana/GrafanaConnectionStringProvider.cs
new file mode 100644
index 000000000..26b494b80
--- /dev/null
+++ b/src/Testcontainers.Grafana/GrafanaConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Grafana;
+
+///
+/// Provides the Grafana connection string.
+///
+internal sealed class GrafanaConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.InfluxDb/InfluxDbBuilder.cs b/src/Testcontainers.InfluxDb/InfluxDbBuilder.cs
index bb23785a1..972afd5c5 100644
--- a/src/Testcontainers.InfluxDb/InfluxDbBuilder.cs
+++ b/src/Testcontainers.InfluxDb/InfluxDbBuilder.cs
@@ -154,6 +154,7 @@ protected override InfluxDbBuilder Init()
.WithPassword(DefaultPassword)
.WithOrganization(DefaultOrganization)
.WithBucket(DefaultBucket)
+ .WithConnectionStringProvider(new InfluxDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPort(InfluxDbPort).ForPath("/ping").ForStatusCode(HttpStatusCode.NoContent)));
}
diff --git a/src/Testcontainers.InfluxDb/InfluxDbConnectionStringProvider.cs b/src/Testcontainers.InfluxDb/InfluxDbConnectionStringProvider.cs
new file mode 100644
index 000000000..ab220ff3d
--- /dev/null
+++ b/src/Testcontainers.InfluxDb/InfluxDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.InfluxDb;
+
+///
+/// Provides the InfluxDb connection string.
+///
+internal sealed class InfluxDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Kafka/KafkaBuilder.cs b/src/Testcontainers.Kafka/KafkaBuilder.cs
index 964aa596a..99e6cbf9e 100644
--- a/src/Testcontainers.Kafka/KafkaBuilder.cs
+++ b/src/Testcontainers.Kafka/KafkaBuilder.cs
@@ -264,7 +264,8 @@ protected override KafkaBuilder Init()
.WithEnvironment("KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS", "0")
.WithEnvironment("CLUSTER_ID", ClusterId)
.WithEntrypoint("/bin/sh", "-c")
- .WithCommand($"while [ ! -f {StartupScriptFilePath} ]; do sleep 0.1; done; {StartupScriptFilePath}");
+ .WithCommand($"while [ ! -f {StartupScriptFilePath} ]; do sleep 0.1; done; {StartupScriptFilePath}")
+ .WithConnectionStringProvider(new KafkaConnectionStringProvider());
}
///
diff --git a/src/Testcontainers.Kafka/KafkaConnectionStringProvider.cs b/src/Testcontainers.Kafka/KafkaConnectionStringProvider.cs
new file mode 100644
index 000000000..692bf1a48
--- /dev/null
+++ b/src/Testcontainers.Kafka/KafkaConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Kafka;
+
+///
+/// Provides the Kafka connection string.
+///
+internal sealed class KafkaConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBootstrapAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Kafka/KafkaContainer.cs b/src/Testcontainers.Kafka/KafkaContainer.cs
index 89a20db5b..b17509c0c 100644
--- a/src/Testcontainers.Kafka/KafkaContainer.cs
+++ b/src/Testcontainers.Kafka/KafkaContainer.cs
@@ -16,15 +16,6 @@ public KafkaContainer(KafkaConfiguration configuration)
_configuration = configuration;
}
- ///
- /// Gets the broker address.
- ///
- /// The broker address.
- public string GetBootstrapAddress()
- {
- return new UriBuilder("PLAINTEXT", Hostname, GetMappedPublicPort(KafkaBuilder.KafkaPort)).ToString();
- }
-
///
/// Gets a list of advertised listeners.
///
@@ -35,4 +26,13 @@ public IEnumerable AdvertisedListeners
return _configuration.AdvertisedListeners;
}
}
+
+ ///
+ /// Gets the broker address.
+ ///
+ /// The broker address.
+ public string GetBootstrapAddress()
+ {
+ return new UriBuilder("PLAINTEXT", Hostname, GetMappedPublicPort(KafkaBuilder.KafkaPort)).ToString();
+ }
}
\ No newline at end of file
diff --git a/src/Testcontainers.Keycloak/KeycloakBuilder.cs b/src/Testcontainers.Keycloak/KeycloakBuilder.cs
index 15f80a802..12672693c 100644
--- a/src/Testcontainers.Keycloak/KeycloakBuilder.cs
+++ b/src/Testcontainers.Keycloak/KeycloakBuilder.cs
@@ -139,7 +139,8 @@ protected override KeycloakBuilder Init()
.WithPortBinding(KeycloakHealthPort, true)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
- .WithEnvironment("KC_HEALTH_ENABLED", "true");
+ .WithEnvironment("KC_HEALTH_ENABLED", "true")
+ .WithConnectionStringProvider(new KeycloakConnectionStringProvider());
}
///
diff --git a/src/Testcontainers.Keycloak/KeycloakConnectionStringProvider.cs b/src/Testcontainers.Keycloak/KeycloakConnectionStringProvider.cs
new file mode 100644
index 000000000..79ffd39bb
--- /dev/null
+++ b/src/Testcontainers.Keycloak/KeycloakConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Keycloak;
+
+///
+/// Provides the Keycloak connection string.
+///
+internal sealed class KeycloakConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.KurrentDb/KurrentDbBuilder.cs b/src/Testcontainers.KurrentDb/KurrentDbBuilder.cs
index 868f71fe2..1d9156ef4 100644
--- a/src/Testcontainers.KurrentDb/KurrentDbBuilder.cs
+++ b/src/Testcontainers.KurrentDb/KurrentDbBuilder.cs
@@ -78,6 +78,7 @@ protected override KurrentDbBuilder Init()
.WithEnvironment("KURRENTDB_RUN_PROJECTIONS", "All")
.WithEnvironment("KURRENTDB_START_STANDARD_PROJECTIONS", "true")
.WithEnvironment("KURRENTDB_INSECURE", "true")
+ .WithConnectionStringProvider(new KurrentDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilContainerIsHealthy());
}
diff --git a/src/Testcontainers.KurrentDb/KurrentDbConnectionStringProvider.cs b/src/Testcontainers.KurrentDb/KurrentDbConnectionStringProvider.cs
new file mode 100644
index 000000000..0ac109155
--- /dev/null
+++ b/src/Testcontainers.KurrentDb/KurrentDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.KurrentDb;
+
+///
+/// Provides the KurrentDb connection string.
+///
+internal sealed class KurrentDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Kusto/KustoBuilder.cs b/src/Testcontainers.Kusto/KustoBuilder.cs
index 227bf0dd4..5bf2a4453 100644
--- a/src/Testcontainers.Kusto/KustoBuilder.cs
+++ b/src/Testcontainers.Kusto/KustoBuilder.cs
@@ -80,6 +80,7 @@ protected override KustoBuilder Init()
return base.Init()
.WithPortBinding(KustoPort, true)
.WithEnvironment("ACCEPT_EULA", "Y")
+ .WithConnectionStringProvider(new KustoConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => request
.WithMethod(HttpMethod.Post)
.ForPort(KustoPort)
diff --git a/src/Testcontainers.Kusto/KustoConnectionStringProvider.cs b/src/Testcontainers.Kusto/KustoConnectionStringProvider.cs
new file mode 100644
index 000000000..f7880a096
--- /dev/null
+++ b/src/Testcontainers.Kusto/KustoConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Kusto;
+
+///
+/// Provides the Kusto connection string.
+///
+internal sealed class KustoConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.LocalStack/LocalStackBuilder.cs b/src/Testcontainers.LocalStack/LocalStackBuilder.cs
index cd0a8e306..aa62d97c9 100644
--- a/src/Testcontainers.LocalStack/LocalStackBuilder.cs
+++ b/src/Testcontainers.LocalStack/LocalStackBuilder.cs
@@ -75,6 +75,7 @@ protected override LocalStackBuilder Init()
{
return base.Init()
.WithPortBinding(LocalStackPort, true)
+ .WithConnectionStringProvider(new LocalStackConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/_localstack/health").ForPort(LocalStackPort)));
}
diff --git a/src/Testcontainers.LocalStack/LocalStackConnectionStringProvider.cs b/src/Testcontainers.LocalStack/LocalStackConnectionStringProvider.cs
new file mode 100644
index 000000000..2e2c99d10
--- /dev/null
+++ b/src/Testcontainers.LocalStack/LocalStackConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.LocalStack;
+
+///
+/// Provides the LocalStack connection string.
+///
+internal sealed class LocalStackConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.LowkeyVault/LowkeyVaultBuilder.cs b/src/Testcontainers.LowkeyVault/LowkeyVaultBuilder.cs
index e356c485f..16de483bf 100644
--- a/src/Testcontainers.LowkeyVault/LowkeyVaultBuilder.cs
+++ b/src/Testcontainers.LowkeyVault/LowkeyVaultBuilder.cs
@@ -95,6 +95,7 @@ protected override LowkeyVaultBuilder Init()
.WithPortBinding(LowkeyVaultPort, true)
.WithPortBinding(LowkeyVaultTokenPort, true)
.WithArguments(new[] { "--LOWKEY_VAULT_RELAXED_PORTS=true" })
+ .WithConnectionStringProvider(new LowkeyVaultConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("(?s).*Started LowkeyVaultApp.*$"));
}
diff --git a/src/Testcontainers.LowkeyVault/LowkeyVaultConnectionStringProvider.cs b/src/Testcontainers.LowkeyVault/LowkeyVaultConnectionStringProvider.cs
new file mode 100644
index 000000000..a72ff9df4
--- /dev/null
+++ b/src/Testcontainers.LowkeyVault/LowkeyVaultConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.LowkeyVault;
+
+///
+/// Provides the Lowkey Vault connection string.
+///
+internal sealed class LowkeyVaultConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.MariaDb/MariaDbBuilder.cs b/src/Testcontainers.MariaDb/MariaDbBuilder.cs
index 55906a95c..b951af03f 100644
--- a/src/Testcontainers.MariaDb/MariaDbBuilder.cs
+++ b/src/Testcontainers.MariaDb/MariaDbBuilder.cs
@@ -122,6 +122,7 @@ protected override MariaDbBuilder Init()
.WithDatabase(DefaultDatabase)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new MariaDbConnectionStringProvider())
.WithStartupCallback((container, ct) => container.WriteConfigurationFileAsync(ct));
}
diff --git a/src/Testcontainers.MariaDb/MariaDbConnectionStringProvider.cs b/src/Testcontainers.MariaDb/MariaDbConnectionStringProvider.cs
new file mode 100644
index 000000000..91fa88f2f
--- /dev/null
+++ b/src/Testcontainers.MariaDb/MariaDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.MariaDb;
+
+///
+/// Provides the MariaDb connection string.
+///
+internal sealed class MariaDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Milvus/MilvusBuilder.cs b/src/Testcontainers.Milvus/MilvusBuilder.cs
index 2eb9c392f..d0ca3eeb7 100644
--- a/src/Testcontainers.Milvus/MilvusBuilder.cs
+++ b/src/Testcontainers.Milvus/MilvusBuilder.cs
@@ -103,6 +103,7 @@ protected override MilvusBuilder Init()
.WithEnvironment("ETCD_CONFIG_PATH", MilvusEtcdConfigFilePath)
.WithEnvironment("ETCD_DATA_DIR", "/var/lib/milvus/etcd")
.WithResourceMapping(EtcdConfig, MilvusEtcdConfigFilePath)
+ .WithConnectionStringProvider(new MilvusConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilContainerIsHealthy())
.WithCreateParameterModifier(parameterModifier =>
parameterModifier.Healthcheck = Healthcheck.Instance);
diff --git a/src/Testcontainers.Milvus/MilvusConnectionStringProvider.cs b/src/Testcontainers.Milvus/MilvusConnectionStringProvider.cs
new file mode 100644
index 000000000..fa39e03cd
--- /dev/null
+++ b/src/Testcontainers.Milvus/MilvusConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Milvus;
+
+///
+/// Provides the Milvus connection string.
+///
+internal sealed class MilvusConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetEndpoint().ToString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Minio/MinioBuilder.cs b/src/Testcontainers.Minio/MinioBuilder.cs
index bd439e9d5..ec44756cf 100644
--- a/src/Testcontainers.Minio/MinioBuilder.cs
+++ b/src/Testcontainers.Minio/MinioBuilder.cs
@@ -104,6 +104,7 @@ protected override MinioBuilder Init()
.WithCommand("server", "/data")
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new MinioConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/minio/health/ready").ForPort(MinioPort)));
}
diff --git a/src/Testcontainers.Minio/MinioConnectionStringProvider.cs b/src/Testcontainers.Minio/MinioConnectionStringProvider.cs
new file mode 100644
index 000000000..8c9673d04
--- /dev/null
+++ b/src/Testcontainers.Minio/MinioConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Minio;
+
+///
+/// Provides the Minio connection string.
+///
+internal sealed class MinioConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.MongoDb/MongoDbBuilder.cs b/src/Testcontainers.MongoDb/MongoDbBuilder.cs
index 997ec5883..d7c0e752b 100644
--- a/src/Testcontainers.MongoDb/MongoDbBuilder.cs
+++ b/src/Testcontainers.MongoDb/MongoDbBuilder.cs
@@ -145,6 +145,7 @@ protected override MongoDbBuilder Init()
.WithPortBinding(MongoDbPort, true)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new MongoDbConnectionStringProvider())
.WithStartupCallback(InitiateReplicaSetAsync);
}
diff --git a/src/Testcontainers.MongoDb/MongoDbConnectionStringProvider.cs b/src/Testcontainers.MongoDb/MongoDbConnectionStringProvider.cs
new file mode 100644
index 000000000..ed27f8d72
--- /dev/null
+++ b/src/Testcontainers.MongoDb/MongoDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.MongoDb;
+
+///
+/// Provides the MongoDb connection string.
+///
+internal sealed class MongoDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Mosquitto/MosquittoBuilder.cs b/src/Testcontainers.Mosquitto/MosquittoBuilder.cs
index 18c396cea..cabbd6b96 100644
--- a/src/Testcontainers.Mosquitto/MosquittoBuilder.cs
+++ b/src/Testcontainers.Mosquitto/MosquittoBuilder.cs
@@ -150,6 +150,7 @@ protected override MosquittoBuilder Init()
return base.Init()
.WithPortBinding(MqttPort, true)
.WithPortBinding(MqttWsPort, true)
+ .WithConnectionStringProvider(new MosquittoConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("mosquitto.*running"));
}
diff --git a/src/Testcontainers.Mosquitto/MosquittoConnectionStringProvider.cs b/src/Testcontainers.Mosquitto/MosquittoConnectionStringProvider.cs
new file mode 100644
index 000000000..89ce85408
--- /dev/null
+++ b/src/Testcontainers.Mosquitto/MosquittoConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Mosquitto;
+
+///
+/// Provides the Mosquitto connection string.
+///
+internal sealed class MosquittoConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.MsSql/MsSqlBuilder.cs b/src/Testcontainers.MsSql/MsSqlBuilder.cs
index b3c362b34..c090b8b91 100644
--- a/src/Testcontainers.MsSql/MsSqlBuilder.cs
+++ b/src/Testcontainers.MsSql/MsSqlBuilder.cs
@@ -97,6 +97,7 @@ protected override MsSqlBuilder Init()
.WithDatabase(DefaultDatabase)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new MsSqlConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new WaitUntil()));
}
diff --git a/src/Testcontainers.MsSql/MsSqlConnectionStringProvider.cs b/src/Testcontainers.MsSql/MsSqlConnectionStringProvider.cs
new file mode 100644
index 000000000..522816407
--- /dev/null
+++ b/src/Testcontainers.MsSql/MsSqlConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.MsSql;
+
+///
+/// Provides the MsSql connection string.
+///
+internal sealed class MsSqlConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.MySql/MySqlBuilder.cs b/src/Testcontainers.MySql/MySqlBuilder.cs
index ff1b52d2d..b312ca814 100644
--- a/src/Testcontainers.MySql/MySqlBuilder.cs
+++ b/src/Testcontainers.MySql/MySqlBuilder.cs
@@ -122,6 +122,7 @@ protected override MySqlBuilder Init()
.WithDatabase(DefaultDatabase)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new MySqlConnectionStringProvider())
.WithStartupCallback((container, ct) => Task.WhenAll(container.CreateMySqlFilesDirectoryAsync(ct), container.WriteConfigurationFileAsync(ct)));
}
diff --git a/src/Testcontainers.MySql/MySqlConnectionStringProvider.cs b/src/Testcontainers.MySql/MySqlConnectionStringProvider.cs
new file mode 100644
index 000000000..5b1c15743
--- /dev/null
+++ b/src/Testcontainers.MySql/MySqlConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.MySql;
+
+///
+/// Provides the MySql connection string.
+///
+internal sealed class MySqlConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Nats/NatsBuilder.cs b/src/Testcontainers.Nats/NatsBuilder.cs
index 8db1eb16e..694d5c138 100644
--- a/src/Testcontainers.Nats/NatsBuilder.cs
+++ b/src/Testcontainers.Nats/NatsBuilder.cs
@@ -109,6 +109,7 @@ protected override NatsBuilder Init()
.WithCommand("--jetstream")
.WithCommand("--debug")
.WithCommand("--trace")
+ .WithConnectionStringProvider(new NatsConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Server is ready"));
}
diff --git a/src/Testcontainers.Nats/NatsConnectionStringProvider.cs b/src/Testcontainers.Nats/NatsConnectionStringProvider.cs
new file mode 100644
index 000000000..0033678de
--- /dev/null
+++ b/src/Testcontainers.Nats/NatsConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Nats;
+
+///
+/// Provides the NATS connection string.
+///
+internal sealed class NatsConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Neo4j/Neo4jBuilder.cs b/src/Testcontainers.Neo4j/Neo4jBuilder.cs
index 70ba8bd3d..e342f8c86 100644
--- a/src/Testcontainers.Neo4j/Neo4jBuilder.cs
+++ b/src/Testcontainers.Neo4j/Neo4jBuilder.cs
@@ -159,6 +159,7 @@ protected override Neo4jBuilder Init()
.WithPortBinding(Neo4jHttpPort, true)
.WithPortBinding(Neo4jBoltPort, true)
.WithEnvironment("NEO4J_AUTH", "none")
+ .WithConnectionStringProvider(new Neo4jConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/").ForPort(Neo4jHttpPort)));
}
diff --git a/src/Testcontainers.Neo4j/Neo4jConnectionStringProvider.cs b/src/Testcontainers.Neo4j/Neo4jConnectionStringProvider.cs
new file mode 100644
index 000000000..6ef9c1937
--- /dev/null
+++ b/src/Testcontainers.Neo4j/Neo4jConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Neo4j;
+
+///
+/// Provides the Neo4j connection string.
+///
+internal sealed class Neo4jConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Ollama/OllamaBuilder.cs b/src/Testcontainers.Ollama/OllamaBuilder.cs
index b85e50ca6..71000443f 100644
--- a/src/Testcontainers.Ollama/OllamaBuilder.cs
+++ b/src/Testcontainers.Ollama/OllamaBuilder.cs
@@ -75,6 +75,7 @@ protected override OllamaBuilder Init()
{
return base.Init()
.WithPortBinding(OllamaPort, true)
+ .WithConnectionStringProvider(new OllamaConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/api/version").ForPort(OllamaPort)));
}
diff --git a/src/Testcontainers.Ollama/OllamaConnectionStringProvider.cs b/src/Testcontainers.Ollama/OllamaConnectionStringProvider.cs
new file mode 100644
index 000000000..f124a9ea7
--- /dev/null
+++ b/src/Testcontainers.Ollama/OllamaConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Ollama;
+
+///
+/// Provides the Ollama connection string.
+///
+internal sealed class OllamaConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.OpenSearch/OpenSearchBuilder.cs b/src/Testcontainers.OpenSearch/OpenSearchBuilder.cs
index b0c90d900..1473006ec 100644
--- a/src/Testcontainers.OpenSearch/OpenSearchBuilder.cs
+++ b/src/Testcontainers.OpenSearch/OpenSearchBuilder.cs
@@ -165,7 +165,8 @@ protected override OpenSearchBuilder Init()
.WithEnvironment("discovery.type", "single-node")
.WithSecurityEnabled()
.WithUsername(DefaultUsername)
- .WithPassword(DefaultPassword);
+ .WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new OpenSearchConnectionStringProvider());
}
///
diff --git a/src/Testcontainers.OpenSearch/OpenSearchConnectionStringProvider.cs b/src/Testcontainers.OpenSearch/OpenSearchConnectionStringProvider.cs
new file mode 100644
index 000000000..c8ad6192e
--- /dev/null
+++ b/src/Testcontainers.OpenSearch/OpenSearchConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.OpenSearch;
+
+///
+/// Provides the OpenSearch connection string.
+///
+internal sealed class OpenSearchConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Oracle/OracleBuilder.cs b/src/Testcontainers.Oracle/OracleBuilder.cs
index 0e3adea27..b4ce74e2d 100644
--- a/src/Testcontainers.Oracle/OracleBuilder.cs
+++ b/src/Testcontainers.Oracle/OracleBuilder.cs
@@ -132,6 +132,7 @@ protected override OracleBuilder Init()
.WithPortBinding(OraclePort, true)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new OracleConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("DATABASE IS READY TO USE!"));
}
diff --git a/src/Testcontainers.Oracle/OracleConnectionStringProvider.cs b/src/Testcontainers.Oracle/OracleConnectionStringProvider.cs
new file mode 100644
index 000000000..90d95f1ff
--- /dev/null
+++ b/src/Testcontainers.Oracle/OracleConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Oracle;
+
+///
+/// Provides the Oracle connection string.
+///
+internal sealed class OracleConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Papercut/PapercutBuilder.cs b/src/Testcontainers.Papercut/PapercutBuilder.cs
index bf0e5c6e3..c591a7177 100644
--- a/src/Testcontainers.Papercut/PapercutBuilder.cs
+++ b/src/Testcontainers.Papercut/PapercutBuilder.cs
@@ -78,6 +78,7 @@ protected override PapercutBuilder Init()
return base.Init()
.WithPortBinding(SmtpPort, true)
.WithPortBinding(HttpPort, true)
+ .WithConnectionStringProvider(new PapercutConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/health").ForPort(HttpPort).ForResponseMessageMatching(IsInstanceHealthyAsync)));
}
diff --git a/src/Testcontainers.Papercut/PapercutConnectionStringProvider.cs b/src/Testcontainers.Papercut/PapercutConnectionStringProvider.cs
new file mode 100644
index 000000000..049f42ec4
--- /dev/null
+++ b/src/Testcontainers.Papercut/PapercutConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Papercut;
+
+///
+/// Provides the Papercut connection string.
+///
+internal sealed class PapercutConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Playwright/PlaywrightBuilder.cs b/src/Testcontainers.Playwright/PlaywrightBuilder.cs
index bbef3f069..f94f34b85 100644
--- a/src/Testcontainers.Playwright/PlaywrightBuilder.cs
+++ b/src/Testcontainers.Playwright/PlaywrightBuilder.cs
@@ -82,7 +82,8 @@ protected override PlaywrightBuilder Init()
.WithEntrypoint("/bin/sh", "-c")
// Extract the Playwright version from the container at startup.
.WithCommand("npx -y playwright@$(sed --quiet 's/.*\\\"driverVersion\\\": *\"\\([^\"]*\\)\".*/\\1/p' ms-playwright/.docker-info) run-server --port " + PlaywrightPort)
- .WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Listening on ws://localhost:8080/"));
+ .WithConnectionStringProvider(new PlaywrightConnectionStringProvider())
+ .WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Listening on ws://localhost:8080/"));
}
///
diff --git a/src/Testcontainers.Playwright/PlaywrightConnectionStringProvider.cs b/src/Testcontainers.Playwright/PlaywrightConnectionStringProvider.cs
new file mode 100644
index 000000000..b723458b8
--- /dev/null
+++ b/src/Testcontainers.Playwright/PlaywrightConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Playwright;
+
+///
+/// Provides the Playwright connection string.
+///
+internal sealed class PlaywrightConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.PostgreSql/PostgreSqlBuilder.cs b/src/Testcontainers.PostgreSql/PostgreSqlBuilder.cs
index 7a13c8cf0..6d9897fd0 100644
--- a/src/Testcontainers.PostgreSql/PostgreSqlBuilder.cs
+++ b/src/Testcontainers.PostgreSql/PostgreSqlBuilder.cs
@@ -124,7 +124,8 @@ protected override PostgreSqlBuilder Init()
// Disable durability: https://www.postgresql.org/docs/current/non-durability.html.
.WithCommand("-c", "fsync=off")
.WithCommand("-c", "full_page_writes=off")
- .WithCommand("-c", "synchronous_commit=off");
+ .WithCommand("-c", "synchronous_commit=off")
+ .WithConnectionStringProvider(new PostgreSqlConnectionStringProvider());
}
///
diff --git a/src/Testcontainers.PostgreSql/PostgreSqlConnectionStringProvider.cs b/src/Testcontainers.PostgreSql/PostgreSqlConnectionStringProvider.cs
new file mode 100644
index 000000000..32b01cdd6
--- /dev/null
+++ b/src/Testcontainers.PostgreSql/PostgreSqlConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.PostgreSql;
+
+///
+/// Provides the PostgreSql connection string.
+///
+internal sealed class PostgreSqlConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.PubSub/PubSubBuilder.cs b/src/Testcontainers.PubSub/PubSubBuilder.cs
index 031d158c4..02c3d0f08 100644
--- a/src/Testcontainers.PubSub/PubSubBuilder.cs
+++ b/src/Testcontainers.PubSub/PubSubBuilder.cs
@@ -77,6 +77,7 @@ protected override PubSubBuilder Init()
.WithPortBinding(PubSubPort, true)
.WithEntrypoint("gcloud")
.WithCommand("beta", "emulators", "pubsub", "start", "--host-port", "0.0.0.0:" + PubSubPort)
+ .WithConnectionStringProvider(new PubSubConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("(?s).*started.*$"));
}
diff --git a/src/Testcontainers.PubSub/PubSubConnectionStringProvider.cs b/src/Testcontainers.PubSub/PubSubConnectionStringProvider.cs
new file mode 100644
index 000000000..56e556266
--- /dev/null
+++ b/src/Testcontainers.PubSub/PubSubConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.PubSub;
+
+///
+/// Provides the PubSub connection string.
+///
+internal sealed class PubSubConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetEmulatorEndpoint();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Pulsar/PulsarBuilder.cs b/src/Testcontainers.Pulsar/PulsarBuilder.cs
index ed056ad29..1767bbbb5 100644
--- a/src/Testcontainers.Pulsar/PulsarBuilder.cs
+++ b/src/Testcontainers.Pulsar/PulsarBuilder.cs
@@ -128,6 +128,7 @@ protected override PulsarBuilder Init()
.WithFunctionsWorker(false)
.WithEntrypoint("/bin/sh", "-c")
.WithCommand("while [ ! -f " + StartupScriptFilePath + " ]; do sleep 0.1; done; " + StartupScriptFilePath)
+ .WithConnectionStringProvider(new PulsarConnectionStringProvider())
.WithStartupCallback((container, ct) => container.CopyStartupScriptAsync(ct));
}
diff --git a/src/Testcontainers.Pulsar/PulsarConnectionStringProvider.cs b/src/Testcontainers.Pulsar/PulsarConnectionStringProvider.cs
new file mode 100644
index 000000000..7a87b9422
--- /dev/null
+++ b/src/Testcontainers.Pulsar/PulsarConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Pulsar;
+
+///
+/// Provides the Pulsar connection string.
+///
+internal sealed class PulsarConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBrokerAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Qdrant/QdrantBuilder.cs b/src/Testcontainers.Qdrant/QdrantBuilder.cs
index d0a829084..55e867b33 100644
--- a/src/Testcontainers.Qdrant/QdrantBuilder.cs
+++ b/src/Testcontainers.Qdrant/QdrantBuilder.cs
@@ -112,7 +112,8 @@ protected override QdrantBuilder Init()
{
return base.Init()
.WithPortBinding(QdrantHttpPort, true)
- .WithPortBinding(QdrantGrpcPort, true);
+ .WithPortBinding(QdrantGrpcPort, true)
+ .WithConnectionStringProvider(new QdrantConnectionStringProvider());
}
///
diff --git a/src/Testcontainers.Qdrant/QdrantConnectionStringProvider.cs b/src/Testcontainers.Qdrant/QdrantConnectionStringProvider.cs
new file mode 100644
index 000000000..b8b5af30a
--- /dev/null
+++ b/src/Testcontainers.Qdrant/QdrantConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Qdrant;
+
+///
+/// Provides the Qdrant connection string.
+///
+internal sealed class QdrantConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetHttpConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.RabbitMq/RabbitMqBuilder.cs b/src/Testcontainers.RabbitMq/RabbitMqBuilder.cs
index 83c8e26ba..1ba390d28 100644
--- a/src/Testcontainers.RabbitMq/RabbitMqBuilder.cs
+++ b/src/Testcontainers.RabbitMq/RabbitMqBuilder.cs
@@ -103,6 +103,7 @@ protected override RabbitMqBuilder Init()
.WithPortBinding(RabbitMqPort, true)
.WithUsername(DefaultUsername)
.WithPassword(DefaultPassword)
+ .WithConnectionStringProvider(new RabbitMqConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Server startup complete"));
}
diff --git a/src/Testcontainers.RabbitMq/RabbitMqConnectionStringProvider.cs b/src/Testcontainers.RabbitMq/RabbitMqConnectionStringProvider.cs
new file mode 100644
index 000000000..2e123e8d1
--- /dev/null
+++ b/src/Testcontainers.RabbitMq/RabbitMqConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.RabbitMq;
+
+///
+/// Provides the RabbitMq connection string.
+///
+internal sealed class RabbitMqConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.RavenDb/RavenDbBuilder.cs b/src/Testcontainers.RavenDb/RavenDbBuilder.cs
index e541cd009..20a8d12a2 100644
--- a/src/Testcontainers.RavenDb/RavenDbBuilder.cs
+++ b/src/Testcontainers.RavenDb/RavenDbBuilder.cs
@@ -75,6 +75,7 @@ protected override RavenDbBuilder Init()
{
return base.Init()
.WithPortBinding(RavenDbPort, true)
+ .WithConnectionStringProvider(new RavenDbConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Server started"));
}
diff --git a/src/Testcontainers.RavenDb/RavenDbConnectionStringProvider.cs b/src/Testcontainers.RavenDb/RavenDbConnectionStringProvider.cs
new file mode 100644
index 000000000..560574f1c
--- /dev/null
+++ b/src/Testcontainers.RavenDb/RavenDbConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.RavenDb;
+
+///
+/// Provides the RavenDb connection string.
+///
+internal sealed class RavenDbConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Redis/RedisBuilder.cs b/src/Testcontainers.Redis/RedisBuilder.cs
index f41c06a3c..af8d82f60 100644
--- a/src/Testcontainers.Redis/RedisBuilder.cs
+++ b/src/Testcontainers.Redis/RedisBuilder.cs
@@ -75,6 +75,7 @@ protected override RedisBuilder Init()
{
return base.Init()
.WithPortBinding(RedisPort, true)
+ .WithConnectionStringProvider(new RedisConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilCommandIsCompleted("redis-cli", "ping"));
}
diff --git a/src/Testcontainers.Redis/RedisConnectionStringProvider.cs b/src/Testcontainers.Redis/RedisConnectionStringProvider.cs
new file mode 100644
index 000000000..382b04111
--- /dev/null
+++ b/src/Testcontainers.Redis/RedisConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Redis;
+
+///
+/// Provides the Redis connection string.
+///
+internal sealed class RedisConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Redpanda/RedpandaBuilder.cs b/src/Testcontainers.Redpanda/RedpandaBuilder.cs
index d57005d64..25c731144 100644
--- a/src/Testcontainers.Redpanda/RedpandaBuilder.cs
+++ b/src/Testcontainers.Redpanda/RedpandaBuilder.cs
@@ -82,6 +82,7 @@ protected override RedpandaBuilder Init()
.WithPortBinding(RedpandaPort, true)
.WithEntrypoint("/bin/sh", "-c")
.WithCommand("while [ ! -f " + StartupScriptFilePath + " ]; do sleep 0.1; done; " + StartupScriptFilePath)
+ .WithConnectionStringProvider(new RedpandaConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Started Kafka API server"))
.WithStartupCallback((container, ct) =>
{
diff --git a/src/Testcontainers.Redpanda/RedpandaConnectionStringProvider.cs b/src/Testcontainers.Redpanda/RedpandaConnectionStringProvider.cs
new file mode 100644
index 000000000..628643e72
--- /dev/null
+++ b/src/Testcontainers.Redpanda/RedpandaConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Redpanda;
+
+///
+/// Provides the Redpanda connection string.
+///
+internal sealed class RedpandaConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBootstrapAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.ServiceBus/ServiceBusBuilder.cs b/src/Testcontainers.ServiceBus/ServiceBusBuilder.cs
index 03aa2df0f..42e6f649a 100644
--- a/src/Testcontainers.ServiceBus/ServiceBusBuilder.cs
+++ b/src/Testcontainers.ServiceBus/ServiceBusBuilder.cs
@@ -164,6 +164,7 @@ protected override ServiceBusBuilder Init()
.WithPortBinding(ServiceBusPort, true)
.WithPortBinding(ServiceBusHttpPort, true)
.WithEnvironment("SQL_WAIT_INTERVAL", "0")
+ .WithConnectionStringProvider(new ServiceBusConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer()
// https://github.com/Azure/azure-event-hubs-emulator-installer/issues/69#issuecomment-3762895979.
.UntilMessageIsLogged("Emulator Service is Successfully Up!")
diff --git a/src/Testcontainers.ServiceBus/ServiceBusConnectionStringProvider.cs b/src/Testcontainers.ServiceBus/ServiceBusConnectionStringProvider.cs
new file mode 100644
index 000000000..d18c1076d
--- /dev/null
+++ b/src/Testcontainers.ServiceBus/ServiceBusConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.ServiceBus;
+
+///
+/// Provides the Service Bus connection string.
+///
+internal sealed class ServiceBusConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Typesense/TypesenseBuilder.cs b/src/Testcontainers.Typesense/TypesenseBuilder.cs
index 6097fd4b6..6fe868728 100644
--- a/src/Testcontainers.Typesense/TypesenseBuilder.cs
+++ b/src/Testcontainers.Typesense/TypesenseBuilder.cs
@@ -101,6 +101,7 @@ protected override TypesenseBuilder Init()
.WithPortBinding(TypesensePort, true)
.WithDataDirectory(DefaultDataDirectory)
.WithApiKey(DefaultApiKey)
+ .WithConnectionStringProvider(new TypesenseConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPort(TypesensePort).ForPath("/health").ForResponseMessageMatching(IsNodeReadyAsync)));
}
diff --git a/src/Testcontainers.Typesense/TypesenseConnectionStringProvider.cs b/src/Testcontainers.Typesense/TypesenseConnectionStringProvider.cs
new file mode 100644
index 000000000..b07050ba7
--- /dev/null
+++ b/src/Testcontainers.Typesense/TypesenseConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Typesense;
+
+///
+/// Provides the Typesense connection string.
+///
+internal sealed class TypesenseConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.Weaviate/WeaviateBuilder.cs b/src/Testcontainers.Weaviate/WeaviateBuilder.cs
index 67a8913e8..e7d6baf6f 100644
--- a/src/Testcontainers.Weaviate/WeaviateBuilder.cs
+++ b/src/Testcontainers.Weaviate/WeaviateBuilder.cs
@@ -73,6 +73,7 @@ protected override WeaviateBuilder Init()
.WithPortBinding(WeaviateGrpcPort, true)
.WithEnvironment("AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED", "true")
.WithEnvironment("PERSISTENCE_DATA_PATH", "/var/lib/weaviate")
+ .WithConnectionStringProvider(new WeaviateConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer()
.UntilInternalTcpPortIsAvailable(WeaviateHttpPort)
.UntilInternalTcpPortIsAvailable(WeaviateGrpcPort)
diff --git a/src/Testcontainers.Weaviate/WeaviateConnectionStringProvider.cs b/src/Testcontainers.Weaviate/WeaviateConnectionStringProvider.cs
new file mode 100644
index 000000000..1a732c485
--- /dev/null
+++ b/src/Testcontainers.Weaviate/WeaviateConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.Weaviate;
+
+///
+/// Provides the Weaviate connection string.
+///
+internal sealed class WeaviateConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetBaseAddress();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers.WebDriver/WebDriverBuilder.cs b/src/Testcontainers.WebDriver/WebDriverBuilder.cs
index b2fe72318..ea66fc13f 100644
--- a/src/Testcontainers.WebDriver/WebDriverBuilder.cs
+++ b/src/Testcontainers.WebDriver/WebDriverBuilder.cs
@@ -169,6 +169,7 @@ protected override WebDriverBuilder Init()
.WithNetworkAliases(WebDriverNetworkAlias)
.WithPortBinding(WebDriverPort, true)
.WithPortBinding(VncServerPort, true)
+ .WithConnectionStringProvider(new WebDriverConnectionStringProvider())
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
request.ForPath("/wd/hub/status").ForPort(WebDriverPort).ForResponseMessageMatching(IsGridReadyAsync)));
}
diff --git a/src/Testcontainers.WebDriver/WebDriverConnectionStringProvider.cs b/src/Testcontainers.WebDriver/WebDriverConnectionStringProvider.cs
new file mode 100644
index 000000000..55dace1be
--- /dev/null
+++ b/src/Testcontainers.WebDriver/WebDriverConnectionStringProvider.cs
@@ -0,0 +1,13 @@
+namespace Testcontainers.WebDriver;
+
+///
+/// Provides the WebDriver connection string.
+///
+internal sealed class WebDriverConnectionStringProvider : ContainerConnectionStringProvider
+{
+ ///
+ protected override string GetHostConnectionString()
+ {
+ return Container.GetConnectionString();
+ }
+}
\ No newline at end of file
diff --git a/src/Testcontainers/Builders/BuildConfiguration.cs b/src/Testcontainers/Builders/BuildConfiguration.cs
index 69136c31c..fdffe458f 100644
--- a/src/Testcontainers/Builders/BuildConfiguration.cs
+++ b/src/Testcontainers/Builders/BuildConfiguration.cs
@@ -12,6 +12,18 @@ namespace DotNet.Testcontainers.Builders
///
public static class BuildConfiguration
{
+ private static class EmptyComposableEnumerableCache
+ {
+ internal static readonly ComposableEnumerable Instance
+ = new AppendEnumerable(Array.Empty());
+ }
+
+ private static class EmptyReadOnlyDictionaryCache
+ {
+ internal static readonly IReadOnlyDictionary Instance
+ = new ReadOnlyDictionary(new Dictionary());
+ }
+
///
/// Returns the updated configuration value. If the new value is null or
/// default, the old value is returned.
@@ -129,7 +141,7 @@ public static ComposableEnumerable Combine(
// the append implementation.
if (newValue == null && oldValue == null)
{
- return new AppendEnumerable(Array.Empty());
+ return EmptyComposableEnumerableCache.Instance;
}
if (newValue == null || oldValue == null)
@@ -155,7 +167,7 @@ public static IReadOnlyDictionary Combine(
{
if (newValue == null && oldValue == null)
{
- return new ReadOnlyDictionary(new Dictionary());
+ return EmptyReadOnlyDictionaryCache.Instance;
}
if (newValue == null)
diff --git a/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs b/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs
index 9f42e8313..c7bd6cf31 100644
--- a/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs
+++ b/tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs
@@ -73,6 +73,7 @@ await producer.SendAsync(producedMessage)
.ConfigureAwait(true);
Assert.Equal(producedMessage.Text, receivedMessage.Body());
+ Assert.Equal(_artemisContainer.GetBrokerAddress(), _artemisContainer.GetConnectionString());
}
// # --8<-- [end:EstablishConnection]
diff --git a/tests/Testcontainers.ArangoDb.Tests/ArangoDbContainerTest.cs b/tests/Testcontainers.ArangoDb.Tests/ArangoDbContainerTest.cs
index 445e49512..c37662f13 100644
--- a/tests/Testcontainers.ArangoDb.Tests/ArangoDbContainerTest.cs
+++ b/tests/Testcontainers.ArangoDb.Tests/ArangoDbContainerTest.cs
@@ -32,5 +32,6 @@ public async Task RetrievesDatabases()
// Then
Assert.Equal(HttpStatusCode.OK, response.Code);
+ Assert.Equal(_arangoDbContainer.GetTransportAddress(), _arangoDbContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs b/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs
index 50d476713..48fbc8ef4 100644
--- a/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs
+++ b/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs
@@ -36,6 +36,7 @@ public async Task EstablishesBlobServiceConnection()
// Then
Assert.False(HasError(properties));
+ Assert.Equal(_azuriteContainer.GetConnectionString(), _azuriteContainer.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.Azurite.Tests/Usings.cs b/tests/Testcontainers.Azurite.Tests/Usings.cs
index 645e958bd..42e30b123 100644
--- a/tests/Testcontainers.Azurite.Tests/Usings.cs
+++ b/tests/Testcontainers.Azurite.Tests/Usings.cs
@@ -7,5 +7,6 @@
global using Azure.Storage.Blobs;
global using Azure.Storage.Queues;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.BigQuery.Tests/BigQueryContainerTest.cs b/tests/Testcontainers.BigQuery.Tests/BigQueryContainerTest.cs
index 86de9138a..12f79fe62 100644
--- a/tests/Testcontainers.BigQuery.Tests/BigQueryContainerTest.cs
+++ b/tests/Testcontainers.BigQuery.Tests/BigQueryContainerTest.cs
@@ -63,6 +63,7 @@ public async Task ExecuteQueryReturnsInsertRow()
Assert.Equal(expectedRow["player"], results.Single()["player"]);
Assert.Equal(expectedRow["gameStarted"], results.Single()["gameStarted"]);
Assert.Equal(expectedRow["score"], results.Single()["score"]);
+ Assert.Equal(_bigQueryContainer.GetEmulatorEndpoint(), _bigQueryContainer.GetConnectionString());
}
private sealed class Credential : ICredential
diff --git a/tests/Testcontainers.Bigtable.Tests/BigtableContainerTest.cs b/tests/Testcontainers.Bigtable.Tests/BigtableContainerTest.cs
index 3a519936a..41b1ad421 100644
--- a/tests/Testcontainers.Bigtable.Tests/BigtableContainerTest.cs
+++ b/tests/Testcontainers.Bigtable.Tests/BigtableContainerTest.cs
@@ -57,5 +57,6 @@ public async Task GetTableReturnsCreateTable()
Assert.Equal(projectId, actualTable.TableName.ProjectId);
Assert.Equal(instanceId, actualTable.TableName.InstanceId);
Assert.Equal(tableId, actualTable.TableName.TableId);
+ Assert.Equal(_bigtableContainer.GetEmulatorEndpoint(), _bigtableContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Cassandra.Tests/CassandraContainerTest.cs b/tests/Testcontainers.Cassandra.Tests/CassandraContainerTest.cs
index 4ff8296a2..c8202b177 100644
--- a/tests/Testcontainers.Cassandra.Tests/CassandraContainerTest.cs
+++ b/tests/Testcontainers.Cassandra.Tests/CassandraContainerTest.cs
@@ -38,6 +38,7 @@ public void ExecuteCqlStatementReturnsExpectedResult()
Assert.True(rowSet.IsFullyFetched);
Assert.Single(rows);
Assert.Equal("COMPLETED", rows[0]["bootstrapped"]);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
// # --8<-- [end:UseCassandraContainer]
diff --git a/tests/Testcontainers.Cassandra.Tests/Usings.cs b/tests/Testcontainers.Cassandra.Tests/Usings.cs
index d54609621..779ae7e75 100644
--- a/tests/Testcontainers.Cassandra.Tests/Usings.cs
+++ b/tests/Testcontainers.Cassandra.Tests/Usings.cs
@@ -6,6 +6,7 @@
global using Cassandra.Data;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Testcontainers.Xunit;
global using Xunit;
diff --git a/tests/Testcontainers.ClickHouse.Tests/ClickHouseContainerTest.cs b/tests/Testcontainers.ClickHouse.Tests/ClickHouseContainerTest.cs
index 5a7e57d4e..0ea2683af 100644
--- a/tests/Testcontainers.ClickHouse.Tests/ClickHouseContainerTest.cs
+++ b/tests/Testcontainers.ClickHouse.Tests/ClickHouseContainerTest.cs
@@ -14,6 +14,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.ClickHouse.Tests/Usings.cs b/tests/Testcontainers.ClickHouse.Tests/Usings.cs
index 937fd7658..55484112a 100644
--- a/tests/Testcontainers.ClickHouse.Tests/Usings.cs
+++ b/tests/Testcontainers.ClickHouse.Tests/Usings.cs
@@ -4,6 +4,7 @@
global using ClickHouse.Client.ADO;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Testcontainers.Xunit;
global using Xunit;
diff --git a/tests/Testcontainers.CockroachDb.Tests/CockroachDbContainerTest.cs b/tests/Testcontainers.CockroachDb.Tests/CockroachDbContainerTest.cs
index 8f1756ca5..c860e9992 100644
--- a/tests/Testcontainers.CockroachDb.Tests/CockroachDbContainerTest.cs
+++ b/tests/Testcontainers.CockroachDb.Tests/CockroachDbContainerTest.cs
@@ -14,6 +14,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.CockroachDb.Tests/Usings.cs b/tests/Testcontainers.CockroachDb.Tests/Usings.cs
index 57c4abd89..83d07319d 100644
--- a/tests/Testcontainers.CockroachDb.Tests/Usings.cs
+++ b/tests/Testcontainers.CockroachDb.Tests/Usings.cs
@@ -3,6 +3,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Npgsql;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.Consul.Tests/ConsulContainerTest.cs b/tests/Testcontainers.Consul.Tests/ConsulContainerTest.cs
index f9c9ce6d6..cc7400151 100644
--- a/tests/Testcontainers.Consul.Tests/ConsulContainerTest.cs
+++ b/tests/Testcontainers.Consul.Tests/ConsulContainerTest.cs
@@ -42,5 +42,6 @@ public async Task GetItemReturnsPutItem()
// Then
Assert.Equal(HttpStatusCode.OK, actual.StatusCode);
Assert.Equal(helloWorld, Encoding.Default.GetString(actual.Response.Value));
+ Assert.Equal(_consulContainer.GetBaseAddress(), _consulContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.CosmosDb.Tests/CosmosDbContainerTest.cs b/tests/Testcontainers.CosmosDb.Tests/CosmosDbContainerTest.cs
index c61f3570e..a7e02821b 100644
--- a/tests/Testcontainers.CosmosDb.Tests/CosmosDbContainerTest.cs
+++ b/tests/Testcontainers.CosmosDb.Tests/CosmosDbContainerTest.cs
@@ -23,7 +23,7 @@ public async Task AccountPropertiesIdReturnsLocalhost()
using var httpClient = _cosmosDbContainer.HttpClient;
var cosmosClientOptions = new CosmosClientOptions();
- cosmosClientOptions.ConnectionMode = ConnectionMode.Gateway;
+ cosmosClientOptions.ConnectionMode = CosmosConnectionMode.Gateway;
cosmosClientOptions.HttpClientFactory = () => httpClient;
using var cosmosClient = new CosmosClient(_cosmosDbContainer.GetConnectionString(), cosmosClientOptions);
@@ -34,5 +34,6 @@ public async Task AccountPropertiesIdReturnsLocalhost()
// Then
Assert.Equal("localhost", accountProperties.Id);
+ Assert.Equal(_cosmosDbContainer.GetConnectionString(), _cosmosDbContainer.GetConnectionString(TestcontainersConnectionMode.Host));
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.CosmosDb.Tests/Usings.cs b/tests/Testcontainers.CosmosDb.Tests/Usings.cs
index 3f12d7755..750c0720a 100644
--- a/tests/Testcontainers.CosmosDb.Tests/Usings.cs
+++ b/tests/Testcontainers.CosmosDb.Tests/Usings.cs
@@ -1,4 +1,6 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
global using Microsoft.Azure.Cosmos;
-global using Xunit;
\ No newline at end of file
+global using Xunit;
+global using CosmosConnectionMode = Microsoft.Azure.Cosmos.ConnectionMode;
+global using TestcontainersConnectionMode = DotNet.Testcontainers.Configurations.ConnectionMode;
\ No newline at end of file
diff --git a/tests/Testcontainers.CouchDb.Tests/CouchDbContainerTest.cs b/tests/Testcontainers.CouchDb.Tests/CouchDbContainerTest.cs
index 9746acfe5..7543d3287 100644
--- a/tests/Testcontainers.CouchDb.Tests/CouchDbContainerTest.cs
+++ b/tests/Testcontainers.CouchDb.Tests/CouchDbContainerTest.cs
@@ -28,5 +28,6 @@ public async Task PutDatabaseReturnsHttpStatusCodeCreated()
// Then
Assert.Equal(HttpStatusCode.Created, database.StatusCode);
+ Assert.Equal(_couchDbContainer.GetConnectionString(), _couchDbContainer.GetConnectionString(ConnectionMode.Host));
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.CouchDb.Tests/Usings.cs b/tests/Testcontainers.CouchDb.Tests/Usings.cs
index b66650bf3..1fc1466f0 100644
--- a/tests/Testcontainers.CouchDb.Tests/Usings.cs
+++ b/tests/Testcontainers.CouchDb.Tests/Usings.cs
@@ -1,5 +1,6 @@
global using System.Net;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using MyCouch;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Couchbase.Tests/CouchbaseContainerTest.cs b/tests/Testcontainers.Couchbase.Tests/CouchbaseContainerTest.cs
index 88838ac58..42582b94d 100644
--- a/tests/Testcontainers.Couchbase.Tests/CouchbaseContainerTest.cs
+++ b/tests/Testcontainers.Couchbase.Tests/CouchbaseContainerTest.cs
@@ -39,5 +39,6 @@ public async Task GetBucketReturnsDefaultBucket()
Assert.NotEmpty(ping.Id);
Assert.NotEmpty(ping.Services);
Assert.NotEmpty(bucket.Name);
+ Assert.Equal(_couchbaseContainer.GetConnectionString(), _couchbaseContainer.GetConnectionString(ConnectionMode.Host));
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Couchbase.Tests/Usings.cs b/tests/Testcontainers.Couchbase.Tests/Usings.cs
index f19c233d3..d159e8894 100644
--- a/tests/Testcontainers.Couchbase.Tests/Usings.cs
+++ b/tests/Testcontainers.Couchbase.Tests/Usings.cs
@@ -2,4 +2,5 @@
global using System.Threading.Tasks;
global using Couchbase;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Db2.Tests/Db2ContainerTest.cs b/tests/Testcontainers.Db2.Tests/Db2ContainerTest.cs
index a1ccab998..1477ace1e 100644
--- a/tests/Testcontainers.Db2.Tests/Db2ContainerTest.cs
+++ b/tests/Testcontainers.Db2.Tests/Db2ContainerTest.cs
@@ -15,6 +15,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.Db2.Tests/Usings.cs b/tests/Testcontainers.Db2.Tests/Usings.cs
index 2b89f65a2..db2415ee9 100644
--- a/tests/Testcontainers.Db2.Tests/Usings.cs
+++ b/tests/Testcontainers.Db2.Tests/Usings.cs
@@ -5,6 +5,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using IBM.Data.Db2;
global using JetBrains.Annotations;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.DynamoDb.Tests/DynamoDbContainerTest.cs b/tests/Testcontainers.DynamoDb.Tests/DynamoDbContainerTest.cs
index 4d569edc4..23c4f9749 100644
--- a/tests/Testcontainers.DynamoDb.Tests/DynamoDbContainerTest.cs
+++ b/tests/Testcontainers.DynamoDb.Tests/DynamoDbContainerTest.cs
@@ -37,6 +37,7 @@ public async Task ListBucketsReturnsHttpStatusCodeOk()
// Then
Assert.Equal(HttpStatusCode.OK, tables.HttpStatusCode);
+ Assert.Equal(_dynamoDbContainer.GetConnectionString(), _dynamoDbContainer.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.DynamoDb.Tests/Usings.cs b/tests/Testcontainers.DynamoDb.Tests/Usings.cs
index 1629ce9dd..532d9edcb 100644
--- a/tests/Testcontainers.DynamoDb.Tests/Usings.cs
+++ b/tests/Testcontainers.DynamoDb.Tests/Usings.cs
@@ -6,4 +6,5 @@
global using Amazon.DynamoDBv2;
global using Amazon.DynamoDBv2.Model;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs b/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs
index f5e3d6929..4debabaf6 100644
--- a/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs
+++ b/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs
@@ -39,6 +39,7 @@ public void PingReturnsValidResponse()
// Then
Assert.True(response.IsValidResponse);
+ Assert.Equal(_elasticsearchContainer.GetConnectionString(), _elasticsearchContainer.GetConnectionString(ConnectionMode.Host));
}
// # --8<-- [end:UseElasticsearchContainer]
diff --git a/tests/Testcontainers.Elasticsearch.Tests/Usings.cs b/tests/Testcontainers.Elasticsearch.Tests/Usings.cs
index 560b71649..1f217dab7 100644
--- a/tests/Testcontainers.Elasticsearch.Tests/Usings.cs
+++ b/tests/Testcontainers.Elasticsearch.Tests/Usings.cs
@@ -1,6 +1,7 @@
global using System;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using Elastic.Clients.Elasticsearch;
global using Elastic.Transport;
global using JetBrains.Annotations;
diff --git a/tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs b/tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs
index e79db35c2..4139170cc 100644
--- a/tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs
+++ b/tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs
@@ -63,6 +63,7 @@ await producer.SendAsync(eventDataBatch, TestContext.Current.CancellationToken)
// Then
Assert.Equal(message, Encoding.UTF8.GetString(asyncEnumerator.Current.Data.Body.Span));
+ Assert.Equal(_eventHubsContainer.GetConnectionString(), _eventHubsContainer.GetConnectionString(ConnectionMode.Host));
}
// # --8<-- [end:UseEventHubsContainer]
diff --git a/tests/Testcontainers.EventHubs.Tests/Usings.cs b/tests/Testcontainers.EventHubs.Tests/Usings.cs
index 312a0abb6..39f6fba40 100644
--- a/tests/Testcontainers.EventHubs.Tests/Usings.cs
+++ b/tests/Testcontainers.EventHubs.Tests/Usings.cs
@@ -6,6 +6,7 @@
global using Azure.Messaging.EventHubs.Producer;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Networks;
global using JetBrains.Annotations;
global using Testcontainers.Azurite;
diff --git a/tests/Testcontainers.FakeGcsServer.Tests/FakeGcsServerContainerTest.cs b/tests/Testcontainers.FakeGcsServer.Tests/FakeGcsServerContainerTest.cs
index 87c703d55..4b7f9d2b5 100644
--- a/tests/Testcontainers.FakeGcsServer.Tests/FakeGcsServerContainerTest.cs
+++ b/tests/Testcontainers.FakeGcsServer.Tests/FakeGcsServerContainerTest.cs
@@ -51,5 +51,6 @@ public async Task DownloadObjectReturnsUploadObject()
// Then
Assert.Equal(helloWorld, Encoding.Default.GetString(readStream.ToArray()));
+ Assert.Equal(_fakeGcsServerContainer.GetConnectionString(), _fakeGcsServerContainer.GetConnectionString(ConnectionMode.Host));
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.FakeGcsServer.Tests/Usings.cs b/tests/Testcontainers.FakeGcsServer.Tests/Usings.cs
index f19546845..d50a3e986 100644
--- a/tests/Testcontainers.FakeGcsServer.Tests/Usings.cs
+++ b/tests/Testcontainers.FakeGcsServer.Tests/Usings.cs
@@ -3,5 +3,6 @@
global using System.Text;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using Google.Cloud.Storage.V1;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.FirebirdSql.Tests/FirebirdSqlContainerTest.cs b/tests/Testcontainers.FirebirdSql.Tests/FirebirdSqlContainerTest.cs
index 7f85a7fe4..bc9add8ee 100644
--- a/tests/Testcontainers.FirebirdSql.Tests/FirebirdSqlContainerTest.cs
+++ b/tests/Testcontainers.FirebirdSql.Tests/FirebirdSqlContainerTest.cs
@@ -14,6 +14,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.FirebirdSql.Tests/Usings.cs b/tests/Testcontainers.FirebirdSql.Tests/Usings.cs
index 85a9ff123..fe93f522e 100644
--- a/tests/Testcontainers.FirebirdSql.Tests/Usings.cs
+++ b/tests/Testcontainers.FirebirdSql.Tests/Usings.cs
@@ -3,6 +3,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using FirebirdSql.Data.FirebirdClient;
global using JetBrains.Annotations;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.Firestore.Tests/FirestoreContainerTest.cs b/tests/Testcontainers.Firestore.Tests/FirestoreContainerTest.cs
index 2b702aca8..d74105f20 100644
--- a/tests/Testcontainers.Firestore.Tests/FirestoreContainerTest.cs
+++ b/tests/Testcontainers.Firestore.Tests/FirestoreContainerTest.cs
@@ -46,5 +46,6 @@ public async Task GetSnapshotReturnsSetDocument()
// Then
Assert.Equal(documentData, querySnapshot.Documents.Select(document => document.ConvertTo>()).Single());
+ Assert.Equal(_firestoreContainer.GetEmulatorEndpoint(), _firestoreContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Grafana.Tests/GrafanaContainerTest.cs b/tests/Testcontainers.Grafana.Tests/GrafanaContainerTest.cs
index 33359a695..d912e8954 100644
--- a/tests/Testcontainers.Grafana.Tests/GrafanaContainerTest.cs
+++ b/tests/Testcontainers.Grafana.Tests/GrafanaContainerTest.cs
@@ -47,6 +47,7 @@ public async Task GetCurrentOrganizationReturnsHttpStatusCodeOk()
// Then
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
+ Assert.Equal(_grafanaContainer.GetBaseAddress(), _grafanaContainer.GetConnectionString());
}
// # --8<-- [end:UseGrafanaContainer]
diff --git a/tests/Testcontainers.InfluxDb.Tests/InfluxDbContainerTest.cs b/tests/Testcontainers.InfluxDb.Tests/InfluxDbContainerTest.cs
index a8c2fc6e7..b04e97c08 100644
--- a/tests/Testcontainers.InfluxDb.Tests/InfluxDbContainerTest.cs
+++ b/tests/Testcontainers.InfluxDb.Tests/InfluxDbContainerTest.cs
@@ -30,6 +30,7 @@ public async Task PingReturnsTrue()
// Then
Assert.True(result);
+ Assert.Equal(_influxDbContainer.GetAddress(), _influxDbContainer.GetConnectionString());
}
[Fact]
diff --git a/tests/Testcontainers.Kafka.Tests/KafkaContainerTest.cs b/tests/Testcontainers.Kafka.Tests/KafkaContainerTest.cs
index 43ddc8e9f..d85c24ea2 100644
--- a/tests/Testcontainers.Kafka.Tests/KafkaContainerTest.cs
+++ b/tests/Testcontainers.Kafka.Tests/KafkaContainerTest.cs
@@ -56,6 +56,7 @@ public async Task ConsumerReturnsProducerMessage()
// Then
Assert.NotNull(result);
Assert.Equal(message.Value, result.Message.Value);
+ Assert.Equal(_kafkaContainer.GetBootstrapAddress(), _kafkaContainer.GetConnectionString());
}
protected virtual ValueTask DisposeAsyncCore()
diff --git a/tests/Testcontainers.Keycloak.Tests/KeycloakContainerTest.cs b/tests/Testcontainers.Keycloak.Tests/KeycloakContainerTest.cs
index 4cfbf368f..47c4830de 100644
--- a/tests/Testcontainers.Keycloak.Tests/KeycloakContainerTest.cs
+++ b/tests/Testcontainers.Keycloak.Tests/KeycloakContainerTest.cs
@@ -37,6 +37,7 @@ public async Task GetOpenIdEndpointReturnsHttpStatusCodeOk()
// Then
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
+ Assert.Equal(_keycloakContainer.GetBaseAddress(), _keycloakContainer.GetConnectionString());
}
[Fact]
diff --git a/tests/Testcontainers.KurrentDb.Tests/KurrentDbContainerTest.cs b/tests/Testcontainers.KurrentDb.Tests/KurrentDbContainerTest.cs
index 4cbe04a41..757861134 100644
--- a/tests/Testcontainers.KurrentDb.Tests/KurrentDbContainerTest.cs
+++ b/tests/Testcontainers.KurrentDb.Tests/KurrentDbContainerTest.cs
@@ -41,5 +41,6 @@ public async Task ReadStreamReturnsEvent()
// Then
Assert.Equal(eventType, resolvedEvent.Event.EventType);
+ Assert.Equal(_kurrentDbContainer.GetConnectionString(), _kurrentDbContainer.GetConnectionString(ConnectionMode.Host));
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.KurrentDb.Tests/Usings.cs b/tests/Testcontainers.KurrentDb.Tests/Usings.cs
index 9fc1fca15..c190cd1f2 100644
--- a/tests/Testcontainers.KurrentDb.Tests/Usings.cs
+++ b/tests/Testcontainers.KurrentDb.Tests/Usings.cs
@@ -2,5 +2,6 @@
global using System.Linq;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using KurrentDB.Client;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Kusto.Tests/KustoContainerTest.cs b/tests/Testcontainers.Kusto.Tests/KustoContainerTest.cs
index eef696fee..7d043029c 100644
--- a/tests/Testcontainers.Kusto.Tests/KustoContainerTest.cs
+++ b/tests/Testcontainers.Kusto.Tests/KustoContainerTest.cs
@@ -31,5 +31,6 @@ public async Task ShowDatabaseReturnsDefaultDbInformation()
// Then
Assert.Equal("DatabaseName", dataReader.GetName(0));
Assert.Equal("NetDefaultDB", dataReader.GetString(0));
+ Assert.Equal(_kustoContainer.GetConnectionString(), _kustoContainer.GetConnectionString(ConnectionMode.Host));
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Kusto.Tests/Usings.cs b/tests/Testcontainers.Kusto.Tests/Usings.cs
index b24f49d27..ca3a50419 100644
--- a/tests/Testcontainers.Kusto.Tests/Usings.cs
+++ b/tests/Testcontainers.Kusto.Tests/Usings.cs
@@ -1,5 +1,6 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using Kusto.Data.Common;
global using Kusto.Data.Net.Client;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.LocalStack.Tests/LocalStackContainerTest.cs b/tests/Testcontainers.LocalStack.Tests/LocalStackContainerTest.cs
index e03c67ab0..357c518c4 100644
--- a/tests/Testcontainers.LocalStack.Tests/LocalStackContainerTest.cs
+++ b/tests/Testcontainers.LocalStack.Tests/LocalStackContainerTest.cs
@@ -50,6 +50,7 @@ public async Task CreateLogReturnsHttpStatusCodeOk()
// Then
Assert.Equal(HttpStatusCode.OK, logGroupResponse.HttpStatusCode);
+ Assert.Equal(_localStackContainer.GetConnectionString(), _localStackContainer.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.LocalStack.Tests/Usings.cs b/tests/Testcontainers.LocalStack.Tests/Usings.cs
index 81dc05551..ed77eb3ed 100644
--- a/tests/Testcontainers.LocalStack.Tests/Usings.cs
+++ b/tests/Testcontainers.LocalStack.Tests/Usings.cs
@@ -11,5 +11,6 @@
global using Amazon.SimpleNotificationService;
global using Amazon.SQS;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs b/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs
index cfd5d0af8..74200c233 100644
--- a/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs
+++ b/tests/Testcontainers.LowkeyVault.Tests/LowkeyVaultContainerTest.cs
@@ -25,15 +25,13 @@ await DisposeAsyncCore()
public async Task ServerCertificateValidationSucceedsWithTrustedCertificate()
{
// Given
- var baseAddress = _lowkeyVaultContainer.GetBaseAddress();
-
var certificates = await _lowkeyVaultContainer.GetCertificateAsync();
using var httpMessageHandler = new HttpClientHandler();
httpMessageHandler.ServerCertificateCustomValidationCallback = (_, cert, _, _) => certificates.IndexOf(cert) > -1;
using var httpClient = new HttpClient(httpMessageHandler);
- httpClient.BaseAddress = new Uri(baseAddress);
+ httpClient.BaseAddress = new Uri(_lowkeyVaultContainer.GetBaseAddress());
// When
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "management/vault");
@@ -43,6 +41,7 @@ public async Task ServerCertificateValidationSucceedsWithTrustedCertificate()
// Then
Assert.Equal(HttpStatusCode.OK, httpResponseMessage.StatusCode);
+ Assert.Equal(_lowkeyVaultContainer.GetBaseAddress(), _lowkeyVaultContainer.GetConnectionString());
}
[Fact]
diff --git a/tests/Testcontainers.MariaDb.Tests/MariaDbContainerTest.cs b/tests/Testcontainers.MariaDb.Tests/MariaDbContainerTest.cs
index 170d9db12..5bb9eae21 100644
--- a/tests/Testcontainers.MariaDb.Tests/MariaDbContainerTest.cs
+++ b/tests/Testcontainers.MariaDb.Tests/MariaDbContainerTest.cs
@@ -14,6 +14,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.MariaDb.Tests/Usings.cs b/tests/Testcontainers.MariaDb.Tests/Usings.cs
index 34433ebc1..64865e2fa 100644
--- a/tests/Testcontainers.MariaDb.Tests/Usings.cs
+++ b/tests/Testcontainers.MariaDb.Tests/Usings.cs
@@ -3,6 +3,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using MySqlConnector;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.Milvus.Tests/MilvusContainerTest.cs b/tests/Testcontainers.Milvus.Tests/MilvusContainerTest.cs
index e03d9bbd3..f17399e3d 100644
--- a/tests/Testcontainers.Milvus.Tests/MilvusContainerTest.cs
+++ b/tests/Testcontainers.Milvus.Tests/MilvusContainerTest.cs
@@ -36,6 +36,7 @@ public async Task GetVersionReturnsExpectedVersion()
// Then
Assert.EndsWith(version, _milvusContainer.Image.Tag);
+ Assert.Equal(_milvusContainer.GetEndpoint().ToString(), _milvusContainer.GetConnectionString());
}
protected virtual ValueTask DisposeAsyncCore()
diff --git a/tests/Testcontainers.Minio.Tests/MinioContainerTest.cs b/tests/Testcontainers.Minio.Tests/MinioContainerTest.cs
index 35831008d..076beb82c 100644
--- a/tests/Testcontainers.Minio.Tests/MinioContainerTest.cs
+++ b/tests/Testcontainers.Minio.Tests/MinioContainerTest.cs
@@ -31,6 +31,7 @@ public async Task ListBucketsReturnsHttpStatusCodeOk()
// Then
Assert.Equal(HttpStatusCode.OK, buckets.HttpStatusCode);
+ Assert.Equal(_minioContainer.GetConnectionString(), _minioContainer.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.Minio.Tests/Usings.cs b/tests/Testcontainers.Minio.Tests/Usings.cs
index d469b39a3..cd1ad6ebf 100644
--- a/tests/Testcontainers.Minio.Tests/Usings.cs
+++ b/tests/Testcontainers.Minio.Tests/Usings.cs
@@ -5,4 +5,5 @@
global using Amazon.S3;
global using Amazon.S3.Model;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs b/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs
index 1c944308b..77df6b465 100644
--- a/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs
+++ b/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs
@@ -39,6 +39,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Contains(databases.ToEnumerable(TestContext.Current.CancellationToken), database => database.TryGetValue("name", out var name) && "admin".Equals(name.AsString));
+ Assert.Equal(_mongoDbContainer.GetConnectionString(), _mongoDbContainer.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.MongoDb.Tests/Usings.cs b/tests/Testcontainers.MongoDb.Tests/Usings.cs
index 6d2e03725..b68e8ba14 100644
--- a/tests/Testcontainers.MongoDb.Tests/Usings.cs
+++ b/tests/Testcontainers.MongoDb.Tests/Usings.cs
@@ -1,6 +1,7 @@
global using System;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using MongoDB.Driver;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Mosquitto.Tests/MosquittoContainerTest.cs b/tests/Testcontainers.Mosquitto.Tests/MosquittoContainerTest.cs
index 5882faf1d..97f4d39f3 100644
--- a/tests/Testcontainers.Mosquitto.Tests/MosquittoContainerTest.cs
+++ b/tests/Testcontainers.Mosquitto.Tests/MosquittoContainerTest.cs
@@ -13,11 +13,11 @@ private MosquittoContainerTest(ITestOutputHelper testOutputHelper)
{
}
+ protected abstract MqttClientOptions GetClientOptions();
+
protected override MosquittoBuilder Configure()
=> new MosquittoBuilder(TestSession.GetImageFromDockerfile());
- protected abstract MqttClientOptions GetClientOptions();
-
[Fact]
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
public async Task EstablishesConnection()
@@ -31,6 +31,7 @@ public async Task EstablishesConnection()
// Then
Assert.Equal(MqttClientConnectResultCode.Success, result.ResultCode);
+ Assert.Equal(Container.GetConnectionString(), Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.Mosquitto.Tests/Usings.cs b/tests/Testcontainers.Mosquitto.Tests/Usings.cs
index f129b6023..df0a8f922 100644
--- a/tests/Testcontainers.Mosquitto.Tests/Usings.cs
+++ b/tests/Testcontainers.Mosquitto.Tests/Usings.cs
@@ -2,6 +2,7 @@
global using System.IO;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using MQTTnet;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs b/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs
index 3e8add598..620f694d2 100644
--- a/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs
+++ b/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs
@@ -15,6 +15,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.MsSql.Tests/Usings.cs b/tests/Testcontainers.MsSql.Tests/Usings.cs
index debde9e33..1eaf2d8be 100644
--- a/tests/Testcontainers.MsSql.Tests/Usings.cs
+++ b/tests/Testcontainers.MsSql.Tests/Usings.cs
@@ -3,6 +3,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Microsoft.Data.SqlClient;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.MySql.Tests/MySqlContainerTest.cs b/tests/Testcontainers.MySql.Tests/MySqlContainerTest.cs
index 7e722329e..a3ee937b4 100644
--- a/tests/Testcontainers.MySql.Tests/MySqlContainerTest.cs
+++ b/tests/Testcontainers.MySql.Tests/MySqlContainerTest.cs
@@ -14,6 +14,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.MySql.Tests/Usings.cs b/tests/Testcontainers.MySql.Tests/Usings.cs
index 34433ebc1..64865e2fa 100644
--- a/tests/Testcontainers.MySql.Tests/Usings.cs
+++ b/tests/Testcontainers.MySql.Tests/Usings.cs
@@ -3,6 +3,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using MySqlConnector;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.Nats.Tests/NatsContainerTest.cs b/tests/Testcontainers.Nats.Tests/NatsContainerTest.cs
index c6726a188..0c5a06772 100644
--- a/tests/Testcontainers.Nats.Tests/NatsContainerTest.cs
+++ b/tests/Testcontainers.Nats.Tests/NatsContainerTest.cs
@@ -63,6 +63,7 @@ public void GetStringReturnsPublishString()
// Then
Assert.Equal(message, actualMessage);
+ Assert.Equal(_natsContainer.GetConnectionString(), _natsContainer.GetConnectionString(ConnectionMode.Host));
}
protected virtual ValueTask DisposeAsyncCore()
diff --git a/tests/Testcontainers.Nats.Tests/Usings.cs b/tests/Testcontainers.Nats.Tests/Usings.cs
index 49a70954e..583abcc70 100644
--- a/tests/Testcontainers.Nats.Tests/Usings.cs
+++ b/tests/Testcontainers.Nats.Tests/Usings.cs
@@ -4,6 +4,7 @@
global using System.Text;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using NATS.Client;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs b/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs
index 29d5abfdc..1e78b56b0 100644
--- a/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs
+++ b/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs
@@ -49,6 +49,7 @@ public async Task SessionReturnsDatabase()
// Then
Assert.Equal(neo4jDatabase, session.SessionConfig.Database);
Assert.Equal(Edition, edition);
+ Assert.Equal(_neo4jContainer.GetConnectionString(), _neo4jContainer.GetConnectionString(ConnectionMode.Host));
}
// # --8<-- [end:UseNeo4jContainer]
diff --git a/tests/Testcontainers.Neo4j.Tests/Usings.cs b/tests/Testcontainers.Neo4j.Tests/Usings.cs
index b7288ff63..a18530f4b 100644
--- a/tests/Testcontainers.Neo4j.Tests/Usings.cs
+++ b/tests/Testcontainers.Neo4j.Tests/Usings.cs
@@ -1,6 +1,7 @@
global using System;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Neo4j.Driver;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Ollama.Tests/OllamaContainerTest.cs b/tests/Testcontainers.Ollama.Tests/OllamaContainerTest.cs
index 0f8e1ddb7..6dfed85f8 100644
--- a/tests/Testcontainers.Ollama.Tests/OllamaContainerTest.cs
+++ b/tests/Testcontainers.Ollama.Tests/OllamaContainerTest.cs
@@ -38,5 +38,6 @@ public async Task GenerateEmbeddingsReturnsEmbeddings()
// Then
Assert.NotNull(embedResponse);
Assert.NotEmpty(embedResponse.Embeddings);
+ Assert.Equal(_ollamaContainer.GetBaseAddress(), _ollamaContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.OpenSearch.Tests/OpenSearchContainerTest.cs b/tests/Testcontainers.OpenSearch.Tests/OpenSearchContainerTest.cs
index 41ecfb803..72bee4d32 100644
--- a/tests/Testcontainers.OpenSearch.Tests/OpenSearchContainerTest.cs
+++ b/tests/Testcontainers.OpenSearch.Tests/OpenSearchContainerTest.cs
@@ -41,6 +41,7 @@ public async Task PingReturnsValidResponse()
// Then
Assert.True(response.IsValid);
+ Assert.Equal(_openSearchContainer.GetConnectionString(), _openSearchContainer.GetConnectionString(ConnectionMode.Host));
}
//
@@ -150,6 +151,7 @@ protected override OpenSearchClient CreateClient()
{
var connectionString = new Uri(_openSearchContainer.GetConnectionString());
Assert.Equal(Uri.UriSchemeHttp, connectionString.Scheme);
+
return new OpenSearchClient(connectionString);
}
}
diff --git a/tests/Testcontainers.OpenSearch.Tests/Usings.cs b/tests/Testcontainers.OpenSearch.Tests/Usings.cs
index e99d10a3d..769d745bc 100644
--- a/tests/Testcontainers.OpenSearch.Tests/Usings.cs
+++ b/tests/Testcontainers.OpenSearch.Tests/Usings.cs
@@ -2,6 +2,7 @@
global using System.Linq;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using OpenSearch.Client;
global using OpenSearch.Net;
diff --git a/tests/Testcontainers.Oracle.Tests/OracleContainerTest.cs b/tests/Testcontainers.Oracle.Tests/OracleContainerTest.cs
index f53d5dac8..3a754ef44 100644
--- a/tests/Testcontainers.Oracle.Tests/OracleContainerTest.cs
+++ b/tests/Testcontainers.Oracle.Tests/OracleContainerTest.cs
@@ -14,6 +14,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.Oracle.Tests/Usings.cs b/tests/Testcontainers.Oracle.Tests/Usings.cs
index 0c2c150f0..a6b3e5f39 100644
--- a/tests/Testcontainers.Oracle.Tests/Usings.cs
+++ b/tests/Testcontainers.Oracle.Tests/Usings.cs
@@ -4,6 +4,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Oracle.ManagedDataAccess.Client;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs
index 057c5bd92..5e1e91e0a 100644
--- a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs
+++ b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs
@@ -38,29 +38,17 @@ public async Task ReceivesSentMessage()
// Then
Assert.Single(messages, message => subject.Equals(message.Subject));
+ Assert.Equal(_papercutContainer.GetBaseAddress(), _papercutContainer.GetConnectionString());
}
- private readonly struct Message
+ private sealed record Message
{
- [JsonConstructor]
- public Message(string id, string subject, string size, DateTime createdAt)
+ public Message(string subject)
{
- Id = id;
Subject = subject;
- Size = size;
- CreatedAt = createdAt;
}
- [JsonPropertyName("id")]
- public string Id { get; }
-
[JsonPropertyName("subject")]
public string Subject { get; }
-
- [JsonPropertyName("size")]
- public string Size { get; }
-
- [JsonPropertyName("createdAt")]
- public DateTime CreatedAt { get; }
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs b/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs
index d855f15b9..fc050dd87 100644
--- a/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs
+++ b/tests/Testcontainers.Playwright.Tests/PlaywrightContainerTest.cs
@@ -65,6 +65,7 @@ await page.GotoAsync(_helloWorldBaseAddress.ToString())
// Then
Assert.Equal("Hello world", headingElementText);
+ Assert.Equal(_playwrightContainer.GetConnectionString(), _playwrightContainer.GetConnectionString(ConnectionMode.Host));
}
// # --8<-- [end:UsePlaywrightContainer]
diff --git a/tests/Testcontainers.Playwright.Tests/Usings.cs b/tests/Testcontainers.Playwright.Tests/Usings.cs
index 30832d99e..70d5c19f0 100644
--- a/tests/Testcontainers.Playwright.Tests/Usings.cs
+++ b/tests/Testcontainers.Playwright.Tests/Usings.cs
@@ -2,6 +2,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs b/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs
index 58cf9ff36..39028958c 100644
--- a/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs
+++ b/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs
@@ -15,6 +15,7 @@ public void ConnectionStateReturnsOpen()
// Then
Assert.Equal(ConnectionState.Open, connection.State);
+ Assert.Equal(fixture.Container.GetConnectionString(), fixture.Container.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.PostgreSql.Tests/Usings.cs b/tests/Testcontainers.PostgreSql.Tests/Usings.cs
index 1da39ede9..859fd8eeb 100644
--- a/tests/Testcontainers.PostgreSql.Tests/Usings.cs
+++ b/tests/Testcontainers.PostgreSql.Tests/Usings.cs
@@ -5,6 +5,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using JetBrains.Annotations;
global using Npgsql;
global using Testcontainers.Xunit;
diff --git a/tests/Testcontainers.PubSub.Tests/PubSubContainerTest.cs b/tests/Testcontainers.PubSub.Tests/PubSubContainerTest.cs
index dfc3cf95a..e3bdbdf65 100644
--- a/tests/Testcontainers.PubSub.Tests/PubSubContainerTest.cs
+++ b/tests/Testcontainers.PubSub.Tests/PubSubContainerTest.cs
@@ -67,5 +67,6 @@ await subscriber.AcknowledgeAsync(subscriptionName, response.ReceivedMessages.Se
// Then
Assert.Equal(helloPubSub, response.ReceivedMessages.Single().Message.Data.ToStringUtf8());
+ Assert.Equal(_pubSubContainer.GetEmulatorEndpoint(), _pubSubContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs b/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs
index 5ba1b59f0..9c225c0df 100644
--- a/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs
+++ b/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs
@@ -74,6 +74,7 @@ public async Task ConsumerReceivesSendMessage()
// Then
Assert.Equal(helloPulsar, Encoding.Default.GetString(message.Data));
+ Assert.Equal(_pulsarContainer.GetBrokerAddress(), _pulsarContainer.GetConnectionString());
}
// # --8<-- [end:UsePulsarContainer]
diff --git a/tests/Testcontainers.Qdrant.Tests/QdrantDefaultContainerTest.cs b/tests/Testcontainers.Qdrant.Tests/QdrantDefaultContainerTest.cs
index d5fe1cd04..b3a03cabe 100644
--- a/tests/Testcontainers.Qdrant.Tests/QdrantDefaultContainerTest.cs
+++ b/tests/Testcontainers.Qdrant.Tests/QdrantDefaultContainerTest.cs
@@ -29,6 +29,7 @@ public async Task HealthReturnsValidResponse()
// Then
Assert.NotEmpty(response.Title);
+ Assert.Equal(_qdrantContainer.GetHttpConnectionString(), _qdrantContainer.GetConnectionString());
}
// # --8<-- [end:UseQdrantContainer]
diff --git a/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs b/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs
index 0561a0ad5..8ee3628bb 100644
--- a/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs
+++ b/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs
@@ -29,6 +29,7 @@ public void IsOpenReturnsTrue()
// Then
Assert.True(connection.IsOpen);
+ Assert.Equal(_rabbitMqContainer.GetConnectionString(), _rabbitMqContainer.GetConnectionString(ConnectionMode.Host));
}
// # --8<-- [end:UseRabbitMqContainer]
}
\ No newline at end of file
diff --git a/tests/Testcontainers.RabbitMq.Tests/Usings.cs b/tests/Testcontainers.RabbitMq.Tests/Usings.cs
index b624b7af6..8ec609a44 100644
--- a/tests/Testcontainers.RabbitMq.Tests/Usings.cs
+++ b/tests/Testcontainers.RabbitMq.Tests/Usings.cs
@@ -1,5 +1,6 @@
global using System;
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using RabbitMQ.Client;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.RavenDb.Tests/RavenDbContainerTest.cs b/tests/Testcontainers.RavenDb.Tests/RavenDbContainerTest.cs
index 56e7870b8..8e36bda50 100644
--- a/tests/Testcontainers.RavenDb.Tests/RavenDbContainerTest.cs
+++ b/tests/Testcontainers.RavenDb.Tests/RavenDbContainerTest.cs
@@ -29,5 +29,6 @@ public void GetBuildNumberOperationReturnsBuildNumber()
// Then
Assert.Contains(buildNumber.ProductVersion, _ravenDbContainer.Image.Tag);
+ Assert.Equal(_ravenDbContainer.GetConnectionString(), _ravenDbContainer.GetConnectionString(ConnectionMode.Host));
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.RavenDb.Tests/Usings.cs b/tests/Testcontainers.RavenDb.Tests/Usings.cs
index efe37ee56..b83fc49ef 100644
--- a/tests/Testcontainers.RavenDb.Tests/Usings.cs
+++ b/tests/Testcontainers.RavenDb.Tests/Usings.cs
@@ -1,5 +1,6 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using Raven.Client.Documents;
global using Raven.Client.ServerWide.Operations;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Redis.Tests/RedisContainerTest.cs b/tests/Testcontainers.Redis.Tests/RedisContainerTest.cs
index 8839205e3..c81201fcd 100644
--- a/tests/Testcontainers.Redis.Tests/RedisContainerTest.cs
+++ b/tests/Testcontainers.Redis.Tests/RedisContainerTest.cs
@@ -21,6 +21,7 @@ public void ConnectionStateReturnsOpen()
{
using var connection = ConnectionMultiplexer.Connect(_redisContainer.GetConnectionString());
Assert.True(connection.IsConnected);
+ Assert.Equal(_redisContainer.GetConnectionString(), _redisContainer.GetConnectionString(ConnectionMode.Host));
}
[Fact]
diff --git a/tests/Testcontainers.Redis.Tests/Usings.cs b/tests/Testcontainers.Redis.Tests/Usings.cs
index 4e7182108..749f9a1b4 100644
--- a/tests/Testcontainers.Redis.Tests/Usings.cs
+++ b/tests/Testcontainers.Redis.Tests/Usings.cs
@@ -1,4 +1,5 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using StackExchange.Redis;
global using Xunit;
\ No newline at end of file
diff --git a/tests/Testcontainers.Redpanda.Tests/RedpandaContainerTest.cs b/tests/Testcontainers.Redpanda.Tests/RedpandaContainerTest.cs
index 1f0330011..c9509cd96 100644
--- a/tests/Testcontainers.Redpanda.Tests/RedpandaContainerTest.cs
+++ b/tests/Testcontainers.Redpanda.Tests/RedpandaContainerTest.cs
@@ -48,5 +48,6 @@ public async Task ConsumerReturnsProducerMessage()
// Then
Assert.NotNull(result);
Assert.Equal(message.Value, result.Message.Value);
+ Assert.Equal(_redpandaContainer.GetBootstrapAddress(), _redpandaContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.ServiceBus.Tests/ServiceBusContainerTest.cs b/tests/Testcontainers.ServiceBus.Tests/ServiceBusContainerTest.cs
index 6b18afbdc..7375e140d 100644
--- a/tests/Testcontainers.ServiceBus.Tests/ServiceBusContainerTest.cs
+++ b/tests/Testcontainers.ServiceBus.Tests/ServiceBusContainerTest.cs
@@ -58,6 +58,7 @@ await sender.SendMessageAsync(message, TestContext.Current.CancellationToken)
// Then
Assert.NotNull(receivedMessage);
Assert.Equal(helloServiceBus, receivedMessage.Body.ToString());
+ Assert.Equal(_serviceBusContainer.GetConnectionString(), _serviceBusContainer.GetConnectionString(ConnectionMode.Host));
}
// # --8<-- [end:UseServiceBusContainer]
diff --git a/tests/Testcontainers.ServiceBus.Tests/Usings.cs b/tests/Testcontainers.ServiceBus.Tests/Usings.cs
index d4f26cebd..470042af1 100644
--- a/tests/Testcontainers.ServiceBus.Tests/Usings.cs
+++ b/tests/Testcontainers.ServiceBus.Tests/Usings.cs
@@ -5,6 +5,7 @@
global using Azure.Messaging.ServiceBus.Administration;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Networks;
global using JetBrains.Annotations;
global using Testcontainers.MsSql;
diff --git a/tests/Testcontainers.Typesense.Tests/TypesenseContainerTest.cs b/tests/Testcontainers.Typesense.Tests/TypesenseContainerTest.cs
index 650746b4d..0d5f02898 100644
--- a/tests/Testcontainers.Typesense.Tests/TypesenseContainerTest.cs
+++ b/tests/Testcontainers.Typesense.Tests/TypesenseContainerTest.cs
@@ -33,5 +33,6 @@ public async Task GetCollectionsReturnsEmptyArray()
// Then
Assert.Equal("[]", response);
+ Assert.Equal(_typesenseContainer.GetBaseAddress(), _typesenseContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.Weaviate.Tests/WeaviateContainerTest.cs b/tests/Testcontainers.Weaviate.Tests/WeaviateContainerTest.cs
index 37711a546..87ee4efee 100644
--- a/tests/Testcontainers.Weaviate.Tests/WeaviateContainerTest.cs
+++ b/tests/Testcontainers.Weaviate.Tests/WeaviateContainerTest.cs
@@ -29,5 +29,6 @@ public async Task GetSchemaReturnsHttpStatusCodeOk()
// Then
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
+ Assert.Equal(_weaviateContainer.GetBaseAddress(), _weaviateContainer.GetConnectionString());
}
}
\ No newline at end of file
diff --git a/tests/Testcontainers.WebDriver.Tests/Usings.cs b/tests/Testcontainers.WebDriver.Tests/Usings.cs
index e490f22c2..5adf224d2 100644
--- a/tests/Testcontainers.WebDriver.Tests/Usings.cs
+++ b/tests/Testcontainers.WebDriver.Tests/Usings.cs
@@ -3,6 +3,7 @@
global using System.Threading.Tasks;
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Commons;
+global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using OpenQA.Selenium.Chrome;
diff --git a/tests/Testcontainers.WebDriver.Tests/WebDriverContainerTest.cs b/tests/Testcontainers.WebDriver.Tests/WebDriverContainerTest.cs
index eb7117a08..df8a20e4c 100644
--- a/tests/Testcontainers.WebDriver.Tests/WebDriverContainerTest.cs
+++ b/tests/Testcontainers.WebDriver.Tests/WebDriverContainerTest.cs
@@ -51,6 +51,7 @@ public void HeadingElementReturnsHelloWorld()
// Then
Assert.Equal("Hello world", headingElementText);
+ Assert.Equal(_webDriverContainer.GetConnectionString(), _webDriverContainer.GetConnectionString(ConnectionMode.Host));
}
protected virtual async ValueTask DisposeAsyncCore()