From ab2a8f587dfb4eda1a9f034fbbc136df54d27e51 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:22:50 +0100 Subject: [PATCH] chore: Add static ctor to ConsoleLogger --- src/Testcontainers.ActiveMq/ArtemisContainer.cs | 6 +++--- src/Testcontainers.MongoDb/MongoDbContainer.cs | 2 +- src/Testcontainers.Nats/NatsContainer.cs | 2 +- src/Testcontainers.RabbitMq/RabbitMqContainer.cs | 2 +- src/Testcontainers/Logger.cs | 4 ++++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Testcontainers.ActiveMq/ArtemisContainer.cs b/src/Testcontainers.ActiveMq/ArtemisContainer.cs index 61416d900..29e96ac8b 100644 --- a/src/Testcontainers.ActiveMq/ArtemisContainer.cs +++ b/src/Testcontainers.ActiveMq/ArtemisContainer.cs @@ -17,12 +17,12 @@ public ArtemisContainer(ActiveMqConfiguration configuration) } /// - /// Gets the broker address. + /// Gets the ActiveMq broker address. /// - /// The broker address. + /// The ActiveMq broker address. public string GetBrokerAddress() { - var endpoint = new UriBuilder("tcp://", Hostname, GetMappedPublicPort(ArtemisBuilder.ArtemisMainPort)); + var endpoint = new UriBuilder("tcp", Hostname, GetMappedPublicPort(ArtemisBuilder.ArtemisMainPort)); endpoint.UserName = Uri.EscapeDataString(_configuration.Username); endpoint.Password = Uri.EscapeDataString(_configuration.Password); return endpoint.ToString(); diff --git a/src/Testcontainers.MongoDb/MongoDbContainer.cs b/src/Testcontainers.MongoDb/MongoDbContainer.cs index f3c4f5e35..25e3531b4 100644 --- a/src/Testcontainers.MongoDb/MongoDbContainer.cs +++ b/src/Testcontainers.MongoDb/MongoDbContainer.cs @@ -23,7 +23,7 @@ public MongoDbContainer(MongoDbConfiguration configuration) public string GetConnectionString() { // The MongoDb documentation recommends to use percent-encoding for username and password: https://www.mongodb.com/docs/manual/reference/connection-string/. - var endpoint = new UriBuilder("mongodb://", Hostname, GetMappedPublicPort(MongoDbBuilder.MongoDbPort)); + var endpoint = new UriBuilder("mongodb", Hostname, GetMappedPublicPort(MongoDbBuilder.MongoDbPort)); endpoint.UserName = Uri.EscapeDataString(_configuration.Username); endpoint.Password = Uri.EscapeDataString(_configuration.Password); return endpoint.ToString(); diff --git a/src/Testcontainers.Nats/NatsContainer.cs b/src/Testcontainers.Nats/NatsContainer.cs index 23d8b2519..24f3e80fc 100644 --- a/src/Testcontainers.Nats/NatsContainer.cs +++ b/src/Testcontainers.Nats/NatsContainer.cs @@ -25,7 +25,7 @@ public NatsContainer(NatsConfiguration configuration) /// A Nats connection string in the format: nats://hostname:port. public string GetConnectionString() { - var endpoint = new UriBuilder("nats://", Hostname, GetMappedPublicPort(NatsBuilder.NatsClientPort)); + var endpoint = new UriBuilder("nats", Hostname, GetMappedPublicPort(NatsBuilder.NatsClientPort)); endpoint.UserName = Uri.EscapeDataString(_configuration.Username); endpoint.Password = Uri.EscapeDataString(_configuration.Password); return endpoint.ToString(); diff --git a/src/Testcontainers.RabbitMq/RabbitMqContainer.cs b/src/Testcontainers.RabbitMq/RabbitMqContainer.cs index 3e6a0fd95..d679e9203 100644 --- a/src/Testcontainers.RabbitMq/RabbitMqContainer.cs +++ b/src/Testcontainers.RabbitMq/RabbitMqContainer.cs @@ -22,7 +22,7 @@ public RabbitMqContainer(RabbitMqConfiguration configuration) /// The RabbitMq connection string. public string GetConnectionString() { - var endpoint = new UriBuilder("amqp://", Hostname, GetMappedPublicPort(RabbitMqBuilder.RabbitMqPort)); + var endpoint = new UriBuilder("amqp", Hostname, GetMappedPublicPort(RabbitMqBuilder.RabbitMqPort)); endpoint.UserName = Uri.EscapeDataString(_configuration.Username); endpoint.Password = Uri.EscapeDataString(_configuration.Password); return endpoint.ToString(); diff --git a/src/Testcontainers/Logger.cs b/src/Testcontainers/Logger.cs index 757a61e9a..e7028ec32 100644 --- a/src/Testcontainers/Logger.cs +++ b/src/Testcontainers/Logger.cs @@ -61,6 +61,10 @@ public sealed class ConsoleLogger : ILogger, IDisposable private LogLevel _minLogLevel = LogLevel.Information; + static ConsoleLogger() + { + } + private ConsoleLogger() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Console.IsOutputRedirected && !Console.IsErrorRedirected)