From 5b3d494d1c78e5715c4e26e7144a05126a960cb1 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Mon, 2 Sep 2024 19:42:59 +0200 Subject: [PATCH] chore: Replace codeinclude with snippets (#1251) --- docs/api/create_docker_container.md | 21 ++++++++++++ docs/custom_configuration/index.md | 24 ++++++++------ docs/examples/aspnet.md | 2 +- docs/examples/dind.md | 4 +-- docs/index.md | 2 +- ...rojects.md => _call_out_test_projects.txt} | 0 docs/modules/elasticsearch.md | 18 ++++++----- docs/modules/index.md | 6 ++-- docs/modules/mongodb.md | 32 +++++++++++-------- docs/modules/mssql.md | 25 ++++++++------- docs/modules/neo4j.md | 18 ++++++----- docs/modules/postgres.md | 18 ++++++----- docs/modules/pulsar.md | 25 ++++++++------- docs/modules/rabbitmq.md | 18 ++++++----- mkdocs.yml | 8 +++-- requirements.txt | 5 ++- .../CouchbaseService.cs | 2 +- .../Configurations/TestcontainersSettings.cs | 2 +- .../ElasticsearchContainerTest.cs | 4 +-- .../Testcontainers.Elasticsearch.Tests.csproj | 4 +-- .../MongoDbContainerTest.cs | 12 +++---- .../Testcontainers.MongoDb.Tests.csproj | 4 +-- .../MsSqlContainerTest.cs | 8 ++--- .../Testcontainers.MsSql.Tests.csproj | 4 +-- .../Neo4jContainerTest.cs | 4 +-- .../Testcontainers.Neo4j.Tests.csproj | 4 +-- .../PostgreSqlContainerTest.cs | 4 +-- .../Testcontainers.PostgreSql.Tests.csproj | 4 +-- .../PulsarContainerTest.cs | 8 ++--- .../Testcontainers.Pulsar.Tests.csproj | 4 +-- .../RabbitMqContainerTest.cs | 4 +-- .../Testcontainers.RabbitMq.Tests.csproj | 4 +-- 32 files changed, 175 insertions(+), 127 deletions(-) rename docs/modules/{_call_out_test_projects.md => _call_out_test_projects.txt} (100%) diff --git a/docs/api/create_docker_container.md b/docs/api/create_docker_container.md index 81ea1b8cc..44a8f5dec 100644 --- a/docs/api/create_docker_container.md +++ b/docs/api/create_docker_container.md @@ -76,6 +76,27 @@ using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(1)); await _container.StartAsync(timeoutCts.Token); ``` +## Getting log messages + +Testcontainers for .NET provides two approaches for retrieving log messages from containers: `GetLogsAsync` and `WithOutputConsumer`. Each method serves different use cases for handling container logs. + +The `GetLogsAsync` method is available through the `IContainer` interface. It allows you to fetch logs from a container for a specific time range or from the beginning until the present. This approach is useful for retrieving logs after a test has run, especially when troubleshooting issues or failures. + +```csharp title="Getting all log messages" +var (stdout, stderr) = await _container.GetLogsAsync(); +``` + +The `WithOutputConsumer` method is part of the `ContainerBuilder` class and is used to continuously forward container log messages to a specified output consumer. This approach provides real-time access to logs as the container runs. + +```csharp title="Forwarding all log messages" +using IOutputConsumer outputConsumer = Consume.RedirectStdoutAndStderrToConsole(); + +_ = new ContainerBuilder() + .WithOutputConsumer(outputConsumer); +``` + +The static class `Consume` offers pre-configured implementations of the `IOutputConsumer` interface for common use cases. If you need additional functionalities beyond those provided by the default implementations, you can create your own implementations of `IOutputConsumer`. + ## Examples An NGINX container that binds the HTTP port to a random host port and hosts static content. The example connects to the web server and checks the HTTP status code. diff --git a/docs/custom_configuration/index.md b/docs/custom_configuration/index.md index 5c3f60634..6598d0ae1 100644 --- a/docs/custom_configuration/index.md +++ b/docs/custom_configuration/index.md @@ -16,27 +16,29 @@ Testcontainers supports various configurations to set up your test environment. | `ryuk.container.privileged` | `TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED` | Runs Ryuk (resource reaper) in privileged mode. | `false` | | `ryuk.container.image` | `TESTCONTAINERS_RYUK_CONTAINER_IMAGE` | The Ryuk (resource reaper) Docker image. | `testcontainers/ryuk:0.5.1` | | `hub.image.name.prefix` | `TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX` | The name to use for substituting the Docker Hub registry part of the image name. | - | - +1) The value represent the string representation of a [TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan), for example, `00:00:01` for 1 second. ## Configure remote container runtime To configure a remote container runtime, Testcontainers provides support for Docker's environment variables in addition to the properties file. During initialization, Testcontainers' auto-discovery feature detect and apply custom configurations including container runtimes. If you are running Docker on a remote host, you can configure it using either of the following methods: -```console title="Properties File" -docker.host=tcp://docker:2375 -``` +=== "Environment Variable" + ``` + DOCKER_HOST=tcp://docker:2375 + ``` -```console title="Environment Variable" -DOCKER_HOST=tcp://docker:2375 -``` +=== "Properties File" + ``` + docker.host=tcp://docker:2375 + ``` ## Enable logging -In .NET logging usually goes through the test framework. Testcontainers is not aware of the project's test framework and may not forward log messages to the appropriate output stream. The default implementation forwards log messages to the `Console` (respectively `stdout` and `stderr`). The output should at least pop up in the IDE running tests in the `Debug` configuration. To override the default implementation, set the `TestcontainersSettings.Logger` property to an instance of an `ILogger` implementation before creating a Docker resource, such as a container. +In .NET logging usually goes through the test framework. Testcontainers is not aware of the project's test framework and may not forward log messages to the appropriate output stream. The default implementation forwards log messages to the `Console` (respectively `stdout` and `stderr`). The output should at least pop up in the IDE running tests in the `Debug` configuration. To override the default implementation, use the builder's `WithLogger(ILogger)` method and provide an `ILogger` instance to replace the default console logger. [testcontainers.org 00:00:00.34] Connected to Docker: Host: tcp://127.0.0.1:60706/ @@ -58,6 +60,10 @@ In .NET logging usually goes through the test framework. Testcontainers is not a [testcontainers.org 00:00:06.26] Start Docker container 027af397344d08d5fc174bf5b5d449f6b352a8a506306d3d96390aaa2bb0445d [testcontainers.org 00:00:06.64] Delete Docker container 027af397344d08d5fc174bf5b5d449f6b352a8a506306d3d96390aaa2bb0445d +!!!tip + + These log messages are from the Testcontainers library and contain information about the test resources. They do not include log messages from the containers. To get the container log messages, see: [Getting log messages](https://dotnet.testcontainers.org/api/create_docker_container/#getting-log-messages). + To enable debug log messages in the default implementation, set the property `ConsoleLogger.Instance.DebugLogLevelEnabled` to `true`. This will forward messages related to building or pulling Docker images to the output stream. [properties-file-format]: https://en.wikipedia.org/wiki/.properties diff --git a/docs/examples/aspnet.md b/docs/examples/aspnet.md index dfde6a277..f56d52099 100644 --- a/docs/examples/aspnet.md +++ b/docs/examples/aspnet.md @@ -75,7 +75,7 @@ The following example adds tests to an ASP.NET Core Blazor application. The test To use Testcontainers' pre-configured Microsoft SQL Server module, add the [Testcontainers.MsSql](https://www.nuget.org/packages/Testcontainers.MsSql) NuGet dependency to your test project: -```console +```shell dotnet add package Testcontainers.MsSql --version 3.0.0 ``` diff --git a/docs/examples/dind.md b/docs/examples/dind.md index 9ec823703..7ee4fb406 100644 --- a/docs/examples/dind.md +++ b/docs/examples/dind.md @@ -6,7 +6,7 @@ If you choose to run your tests in a Docker Wormhole configuration, which involves using sibling containers, it is necessary to mount Docker's raw socket `/var/run/docker.sock.raw`. You find more information and an explanation of the Docker bug in this [comment](https://github.com/docker/for-mac/issues/5588#issuecomment-934600089). -```console +```shell docker run -v /var/run/docker.sock.raw:/var/run/docker.sock $IMAGE dotnet test ``` @@ -29,7 +29,7 @@ services: entrypoint: dotnet command: test # Uncomment the lines below in the case of Docker Desktop (see note above). - # TESTCONTAINERS_HOST_OVERRIDE is not needed in the case of Docker Engine. + # TESTCONTAINERS_HOST_OVERRIDE is not needed in the case of Docker Engine. # environment: # - TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal volumes: diff --git a/docs/index.md b/docs/index.md index 135e8c274..c1229046c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ # Welcome to Testcontainers for .NET! -```console title="Install the NuGet dependency" +```shell title="Install the NuGet dependency" dotnet add package Testcontainers ``` diff --git a/docs/modules/_call_out_test_projects.md b/docs/modules/_call_out_test_projects.txt similarity index 100% rename from docs/modules/_call_out_test_projects.md rename to docs/modules/_call_out_test_projects.txt diff --git a/docs/modules/elasticsearch.md b/docs/modules/elasticsearch.md index 24c7ffcda..c94df0fa5 100644 --- a/docs/modules/elasticsearch.md +++ b/docs/modules/elasticsearch.md @@ -4,25 +4,27 @@ Add the following dependency to your project file: -```console title="NuGet" +```shell title="NuGet" dotnet add package Testcontainers.Elasticsearch ``` You can start an Elasticsearch container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. - -[Usage Example](../../tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs) inside_block:UseElasticsearchContainer - +=== "Usage Example" + ```csharp + --8<-- "tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs:UseElasticsearchContainer" + ``` The test example uses the following NuGet dependencies: - -[Package References](../../tests/Testcontainers.Elasticsearch.Tests/Testcontainers.Elasticsearch.Tests.csproj) inside_block:PackageReferences - +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.Elasticsearch.Tests/Testcontainers.Elasticsearch.Tests.csproj:PackageReferences" + ``` To execute the tests, use the command `dotnet test` from a terminal. ---8<-- "docs/modules/_call_out_test_projects.md" +--8<-- "docs/modules/_call_out_test_projects.txt" ## A Note To Developers diff --git a/docs/modules/index.md b/docs/modules/index.md index e7455d187..1bd6f315c 100644 --- a/docs/modules/index.md +++ b/docs/modules/index.md @@ -4,7 +4,7 @@ Modules are great examples of Testcontainers' capabilities. To write tests again Modules are standalone dependencies that can be installed from [NuGet.org](https://www.nuget.org/profiles/Testcontainers). To use a module in your test project, you need to add it as a dependency first: -```console +```shell dotnet add package Testcontainers.ModuleName ``` @@ -69,7 +69,7 @@ await moduleNameContainer.StartAsync(); The Testcontainers for .NET repository contains a .NET [template](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Templates) to scaffold advanced modules quickly. To create and add a new module to the Testcontainers solution file, checkout the repository and install the .NET template first: -```console +```shell git clone --branch develop git@github.com:testcontainers/testcontainers-dotnet.git cd ./testcontainers-dotnet/ dotnet new --install ./src/Templates @@ -77,7 +77,7 @@ dotnet new --install ./src/Templates The following CLI commands create and add a new PostgreSQL module to the solution file: -```console +```shell dotnet new tcm --name PostgreSql --official-module true --output ./src dotnet sln add ./src/Testcontainers.PostgreSql/Testcontainers.PostgreSql.csproj ``` diff --git a/docs/modules/mongodb.md b/docs/modules/mongodb.md index ff4be3cb8..192ae1be2 100644 --- a/docs/modules/mongodb.md +++ b/docs/modules/mongodb.md @@ -4,36 +4,40 @@ Add the following dependency to your project file: -```console title="NuGet" +```shell title="NuGet" dotnet add package Testcontainers.MongoDb ``` You can start a MongoDB container instance from any .NET application. Here, we create different container instances and pass them to the base test class. This allows us to test different configurations. - -[Create Container Instance](../../tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs) inside_block:CreateMongoDbContainer - +=== "Create Container Instance" + ```csharp + --8<-- "tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs:CreateMongoDbContainer" + ``` This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. - -[Usage Example](../../tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs) inside_block:UseMongoDbContainer - +=== "Usage Example" + ```csharp + --8<-- "tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs:UseMongoDbContainer" + ``` The test example uses the following NuGet dependencies: - -[Package References](../../tests/Testcontainers.MongoDb.Tests/Testcontainers.MongoDb.Tests.csproj) inside_block:PackageReferences - +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.MongoDb.Tests/Testcontainers.MongoDb.Tests.csproj:PackageReferences" + ``` To execute the tests, use the command `dotnet test` from a terminal. ---8<-- "docs/modules/_call_out_test_projects.md" +--8<-- "docs/modules/_call_out_test_projects.txt" ## MongoDb Replica Set By default, MongoDB runs as a standalone instance. If your tests require a MongoDB replica set, use the following configuration which will initialize a single-node replica set: - -[Replica Set Configuration](../../tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs) inside_block:ReplicaSetContainerConfiguration - \ No newline at end of file +=== "Replica Set Configuration" + ```csharp + --8<-- "tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs:ReplicaSetContainerConfiguration" + ``` \ No newline at end of file diff --git a/docs/modules/mssql.md b/docs/modules/mssql.md index 30f4f9bfe..64b52faa5 100644 --- a/docs/modules/mssql.md +++ b/docs/modules/mssql.md @@ -4,31 +4,34 @@ Add the following dependency to your project file: -```console title="NuGet" +```shell title="NuGet" dotnet add package Testcontainers.MsSql ``` You can start a MSSQL container instance from any .NET application. Here, we create different container instances and pass them to the base test class. This allows us to test different configurations. - -[Create Container Instance](../../tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs) inside_block:CreateMsSqlContainer - +=== "Create Container Instance" + ```csharp + --8<-- "tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs:CreateMsSqlContainer" + ``` This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. - -[Usage Example](../../tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs) inside_block:UseMsSqlContainer - +=== "Usage Example" + ```csharp + --8<-- "tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs:UseMsSqlContainer" + ``` The test example uses the following NuGet dependencies: - -[Package References](../../tests/Testcontainers.MsSql.Tests/Testcontainers.MsSql.Tests.csproj) inside_block:PackageReferences - +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.MsSql.Tests/Testcontainers.MsSql.Tests.csproj:PackageReferences" + ``` To execute the tests, use the command `dotnet test` from a terminal. ---8<-- "docs/modules/_call_out_test_projects.md" +--8<-- "docs/modules/_call_out_test_projects.txt" ## A Note To Developers diff --git a/docs/modules/neo4j.md b/docs/modules/neo4j.md index 2e0038c2e..6f6f0d12b 100644 --- a/docs/modules/neo4j.md +++ b/docs/modules/neo4j.md @@ -4,22 +4,24 @@ Add the following dependency to your project file: -```console title="NuGet" +```shell title="NuGet" dotnet add package Testcontainers.Neo4j ``` You can start an Neo4j container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. - -[Usage Example](../../tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs) inside_block:UseNeo4jContainer - +=== "Usage Example" + ```csharp + --8<-- "tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs:UseNeo4jContainer" + ``` The test example uses the following NuGet dependencies: - -[Package References](../../tests/Testcontainers.Neo4j.Tests/Testcontainers.Neo4j.Tests.csproj) inside_block:PackageReferences - +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.Neo4j.Tests/Testcontainers.Neo4j.Tests.csproj:PackageReferences" + ``` To execute the tests, use the command `dotnet test` from a terminal. ---8<-- "docs/modules/_call_out_test_projects.md" \ No newline at end of file +--8<-- "docs/modules/_call_out_test_projects.txt" \ No newline at end of file diff --git a/docs/modules/postgres.md b/docs/modules/postgres.md index eeff3f1e3..b38611e4d 100644 --- a/docs/modules/postgres.md +++ b/docs/modules/postgres.md @@ -4,22 +4,24 @@ Add the following dependency to your project file: -```console title="NuGet" +```shell title="NuGet" dotnet add package Testcontainers.PostgreSql ``` You can start an PostgreSQL container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. - -[Usage Example](../../tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs) inside_block:UsePostgreSqlContainer - +=== "Usage Example" + ```csharp + --8<-- "tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs:UsePostgreSqlContainer" + ``` The test example uses the following NuGet dependencies: - -[Package References](../../tests/Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj) inside_block:PackageReferences - +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj:PackageReferences" + ``` To execute the tests, use the command `dotnet test` from a terminal. ---8<-- "docs/modules/_call_out_test_projects.md" \ No newline at end of file +--8<-- "docs/modules/_call_out_test_projects.txt" \ No newline at end of file diff --git a/docs/modules/pulsar.md b/docs/modules/pulsar.md index 05818ccd7..f1c5627ff 100644 --- a/docs/modules/pulsar.md +++ b/docs/modules/pulsar.md @@ -4,31 +4,34 @@ Add the following dependency to your project file: -```console title="NuGet" +```shell title="NuGet" dotnet add package Testcontainers.Pulsar ``` You can start a Apache Pulsar container instance from any .NET application. Here, we create different container instances and pass them to the base test class. This allows us to test different configurations. - -[Create Container Instance](../../tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs) inside_block:CreatePulsarContainer - +=== "Create Container Instance" + ```csharp + --8<-- "tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs:CreatePulsarContainer" + ``` This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. - -[Usage Example](../../tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs) inside_block:UsePulsarContainer - +=== "Usage Example" + ```csharp + --8<-- "tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs:UsePulsarContainer" + ``` The test example uses the following NuGet dependencies: - -[Package References](../../tests/Testcontainers.Pulsar.Tests/Testcontainers.Pulsar.Tests.csproj) inside_block:PackageReferences - +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.Pulsar.Tests/Testcontainers.Pulsar.Tests.csproj:PackageReferences" + ``` To execute the tests, use the command `dotnet test` from a terminal. ---8<-- "docs/modules/_call_out_test_projects.md" +--8<-- "docs/modules/_call_out_test_projects.txt" ## Access Apache Pulsar diff --git a/docs/modules/rabbitmq.md b/docs/modules/rabbitmq.md index 39ac69d33..6c9589d8c 100644 --- a/docs/modules/rabbitmq.md +++ b/docs/modules/rabbitmq.md @@ -4,22 +4,24 @@ Add the following dependency to your project file: -```console title="NuGet" +```shell title="NuGet" dotnet add package Testcontainers.RabbitMq ``` You can start a RabbitMQ container instance from any .NET application. This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the container. The container is started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the container is removed in the `DisposeAsync` method. - -[Usage Example](../../tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs) inside_block:UseRabbitMqContainer - +=== "Usage Example" + ```csharp + --8<-- "tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs:UseRabbitMqContainer" + ``` The test example uses the following NuGet dependencies: - -[Package References](../../tests/Testcontainers.RabbitMq.Tests/Testcontainers.RabbitMq.Tests.csproj) inside_block:PackageReferences - +=== "Package References" + ```xml + --8<-- "tests/Testcontainers.RabbitMq.Tests/Testcontainers.RabbitMq.Tests.csproj:PackageReferences" + ``` To execute the tests, use the command `dotnet test` from a terminal. ---8<-- "docs/modules/_call_out_test_projects.md" \ No newline at end of file +--8<-- "docs/modules/_call_out_test_projects.txt" \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 1eb519b0b..74bcffd12 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -17,13 +17,15 @@ extra_css: - css/extra.css - css/tc-header.css plugins: - - codeinclude - markdownextradata - search markdown_extensions: - admonition - pymdownx.details - - pymdownx.snippets + - pymdownx.highlight: + linenums: true + - pymdownx.snippets: + dedent_subsections: true - pymdownx.superfences - pymdownx.tabbed: alternate_style: true @@ -50,3 +52,5 @@ nav: - modules/postgres.md - modules/pulsar.md - modules/rabbitmq.md + - contributing.md + - contributing_docs.md \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f4fd8cbd9..304cb44c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -mkdocs==1.4.3 -mkdocs-codeinclude-plugin==0.2.1 -mkdocs-markdownextradata-plugin==0.2.5 +mkdocs==1.6.1 +mkdocs-markdownextradata-plugin==0.2.6 mkdocs-material==8.5.11 diff --git a/src/Testcontainers.Couchbase/CouchbaseService.cs b/src/Testcontainers.Couchbase/CouchbaseService.cs index 806dbcbc0..a90f38789 100644 --- a/src/Testcontainers.Couchbase/CouchbaseService.cs +++ b/src/Testcontainers.Couchbase/CouchbaseService.cs @@ -3,7 +3,7 @@ namespace Testcontainers.Couchbase; /// /// A Couchbase service. /// -internal readonly struct CouchbaseService +internal readonly record struct CouchbaseService { /// /// Gets the Data service. diff --git a/src/Testcontainers/Configurations/TestcontainersSettings.cs b/src/Testcontainers/Configurations/TestcontainersSettings.cs index c2b5146b8..efb611a91 100644 --- a/src/Testcontainers/Configurations/TestcontainersSettings.cs +++ b/src/Testcontainers/Configurations/TestcontainersSettings.cs @@ -141,7 +141,7 @@ static TestcontainersSettings() /// [NotNull] public static IOperatingSystem OS { get; set; } - = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (IOperatingSystem)new Windows(DockerEndpointAuthConfig) : new Unix(DockerEndpointAuthConfig); + = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? new Windows(DockerEndpointAuthConfig) : new Unix(DockerEndpointAuthConfig); /// public static Task ExposeHostPortsAsync(ushort port, CancellationToken ct = default) diff --git a/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs b/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs index 974f628c4..64d367921 100644 --- a/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs +++ b/tests/Testcontainers.Elasticsearch.Tests/ElasticsearchContainerTest.cs @@ -2,7 +2,7 @@ namespace Testcontainers.Elasticsearch; public sealed class ElasticsearchContainerTest : IAsyncLifetime { - // UseElasticsearchContainer { + // # --8<-- [start:UseElasticsearchContainer] private readonly ElasticsearchContainer _elasticsearchContainer = new ElasticsearchBuilder().Build(); public Task InitializeAsync() @@ -31,5 +31,5 @@ public void PingReturnsValidResponse() // Then Assert.True(response.IsValidResponse); } - // } + // # --8<-- [end:UseElasticsearchContainer] } \ No newline at end of file diff --git a/tests/Testcontainers.Elasticsearch.Tests/Testcontainers.Elasticsearch.Tests.csproj b/tests/Testcontainers.Elasticsearch.Tests/Testcontainers.Elasticsearch.Tests.csproj index a6224b845..d03e63d9d 100644 --- a/tests/Testcontainers.Elasticsearch.Tests/Testcontainers.Elasticsearch.Tests.csproj +++ b/tests/Testcontainers.Elasticsearch.Tests/Testcontainers.Elasticsearch.Tests.csproj @@ -5,13 +5,13 @@ false - + - + diff --git a/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs b/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs index c71557072..0b7b66a42 100644 --- a/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs +++ b/tests/Testcontainers.MongoDb.Tests/MongoDbContainerTest.cs @@ -12,7 +12,7 @@ private MongoDbContainerTest(MongoDbContainer mongoDbContainer, bool replicaSetE _replicaSetEnabled = replicaSetEnabled; } - // UseMongoDbContainer { + // # --8<-- [start:UseMongoDbContainer] public Task InitializeAsync() { return _mongoDbContainer.StartAsync(); @@ -52,7 +52,7 @@ public async Task ExecScriptReturnsSuccessful() Assert.True(0L.Equals(execResult.ExitCode), execResult.Stderr); Assert.Empty(execResult.Stderr); } - // } + // # --8<-- [end:UseMongoDbContainer] [Fact] [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] @@ -78,7 +78,7 @@ public async Task ReplicaSetStatus() } } - // CreateMongoDbContainer { + // # --8<-- [start:CreateMongoDbContainer] [UsedImplicitly] public sealed class MongoDbDefaultConfiguration : MongoDbContainerTest { @@ -96,7 +96,7 @@ public MongoDbNoAuthConfiguration() { } } - // } + // # --8<-- [end:CreateMongoDbContainer] [UsedImplicitly] public sealed class MongoDbV5Configuration : MongoDbContainerTest @@ -125,7 +125,7 @@ public MongoDbReplicaSetDefaultConfiguration() } } - // ReplicaSetContainerConfiguration { + // # --8<-- [start:ReplicaSetContainerConfiguration] [UsedImplicitly] public sealed class MongoDbNamedReplicaSetConfiguration : MongoDbContainerTest { @@ -134,5 +134,5 @@ public MongoDbNamedReplicaSetConfiguration() { } } - // } + // # --8<-- [end:ReplicaSetContainerConfiguration] } \ No newline at end of file diff --git a/tests/Testcontainers.MongoDb.Tests/Testcontainers.MongoDb.Tests.csproj b/tests/Testcontainers.MongoDb.Tests/Testcontainers.MongoDb.Tests.csproj index d50ee4594..4afae395e 100644 --- a/tests/Testcontainers.MongoDb.Tests/Testcontainers.MongoDb.Tests.csproj +++ b/tests/Testcontainers.MongoDb.Tests/Testcontainers.MongoDb.Tests.csproj @@ -5,13 +5,13 @@ false - + - + diff --git a/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs b/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs index 3e65695cc..64e15d2aa 100644 --- a/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs +++ b/tests/Testcontainers.MsSql.Tests/MsSqlContainerTest.cs @@ -9,7 +9,7 @@ public MsSqlContainerTest(MsSqlContainer msSqlContainer) _msSqlContainer = msSqlContainer; } - // UseMsSqlContainer { + // # --8<-- [start:UseMsSqlContainer] public Task InitializeAsync() { return _msSqlContainer.StartAsync(); @@ -49,9 +49,9 @@ public async Task ExecScriptReturnsSuccessful() Assert.True(0L.Equals(execResult.ExitCode), execResult.Stderr); Assert.Empty(execResult.Stderr); } - // } + // # --8<-- [end:UseMsSqlContainer] - // CreateMsSqlContainer { + // # --8<-- [start:CreateMsSqlContainer] [UsedImplicitly] public sealed class MsSqlDefaultConfiguration : MsSqlContainerTest { @@ -60,7 +60,7 @@ public MsSqlDefaultConfiguration() { } } - // } + // # --8<-- [end:CreateMsSqlContainer] [UsedImplicitly] public sealed class MsSqlTools18Configuration : MsSqlContainerTest diff --git a/tests/Testcontainers.MsSql.Tests/Testcontainers.MsSql.Tests.csproj b/tests/Testcontainers.MsSql.Tests/Testcontainers.MsSql.Tests.csproj index 2ef4d6469..506e8b9f1 100644 --- a/tests/Testcontainers.MsSql.Tests/Testcontainers.MsSql.Tests.csproj +++ b/tests/Testcontainers.MsSql.Tests/Testcontainers.MsSql.Tests.csproj @@ -5,13 +5,13 @@ false - + - + diff --git a/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs b/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs index 9609e557b..460b38934 100644 --- a/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs +++ b/tests/Testcontainers.Neo4j.Tests/Neo4jContainerTest.cs @@ -2,7 +2,7 @@ namespace Testcontainers.Neo4j; public sealed class Neo4jContainerTest : IAsyncLifetime { - // UseNeo4jContainer { + // # --8<-- [start:UseNeo4jContainer] private readonly Neo4jContainer _neo4jContainer = new Neo4jBuilder().Build(); public Task InitializeAsync() @@ -30,5 +30,5 @@ public void SessionReturnsDatabase() // Then Assert.Equal(database, session.SessionConfig.Database); } - // } + // # --8<-- [end:UseNeo4jContainer] } \ No newline at end of file diff --git a/tests/Testcontainers.Neo4j.Tests/Testcontainers.Neo4j.Tests.csproj b/tests/Testcontainers.Neo4j.Tests/Testcontainers.Neo4j.Tests.csproj index 91d78f450..87c46a36f 100644 --- a/tests/Testcontainers.Neo4j.Tests/Testcontainers.Neo4j.Tests.csproj +++ b/tests/Testcontainers.Neo4j.Tests/Testcontainers.Neo4j.Tests.csproj @@ -5,13 +5,13 @@ false - + - + diff --git a/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs b/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs index ab03d8aa9..e797eaaa3 100644 --- a/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs +++ b/tests/Testcontainers.PostgreSql.Tests/PostgreSqlContainerTest.cs @@ -2,7 +2,7 @@ namespace Testcontainers.PostgreSql; public sealed class PostgreSqlContainerTest : IAsyncLifetime { - // UsePostgreSqlContainer { + // # --8<-- [start:UsePostgreSqlContainer] private readonly PostgreSqlContainer _postgreSqlContainer = new PostgreSqlBuilder().Build(); public Task InitializeAsync() @@ -44,7 +44,7 @@ public async Task ExecScriptReturnsSuccessful() Assert.True(0L.Equals(execResult.ExitCode), execResult.Stderr); Assert.Empty(execResult.Stderr); } - // } + // # --8<-- [end:UsePostgreSqlContainer] public sealed class ReuseContainerTest : IClassFixture, IDisposable { diff --git a/tests/Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj b/tests/Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj index 6c20b7979..a072d6b9d 100644 --- a/tests/Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj +++ b/tests/Testcontainers.PostgreSql.Tests/Testcontainers.PostgreSql.Tests.csproj @@ -5,13 +5,13 @@ false - + - + diff --git a/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs b/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs index 41b71f6cf..d5a45498a 100644 --- a/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs +++ b/tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs @@ -12,7 +12,7 @@ private PulsarContainerTest(PulsarContainer pulsarContainer, bool authentication _authenticationEnabled = authenticationEnabled; } - // UsePulsarContainer { + // # --8<-- [start:UsePulsarContainer] public Task InitializeAsync() { return _pulsarContainer.StartAsync(); @@ -63,9 +63,9 @@ public async Task ConsumerReceivesSendMessage() // Then Assert.Equal(helloPulsar, Encoding.Default.GetString(message.Data)); } - // } + // # --8<-- [end:UsePulsarContainer] - // CreatePulsarContainer { + // # --8<-- [start:CreatePulsarContainer] [UsedImplicitly] public sealed class PulsarDefaultConfiguration : PulsarContainerTest { @@ -74,7 +74,7 @@ public PulsarDefaultConfiguration() { } } - // } + // # --8<-- [end:CreatePulsarContainer] [UsedImplicitly] public sealed class PulsarAuthConfiguration : PulsarContainerTest diff --git a/tests/Testcontainers.Pulsar.Tests/Testcontainers.Pulsar.Tests.csproj b/tests/Testcontainers.Pulsar.Tests/Testcontainers.Pulsar.Tests.csproj index 63d41e13c..41dd297d7 100644 --- a/tests/Testcontainers.Pulsar.Tests/Testcontainers.Pulsar.Tests.csproj +++ b/tests/Testcontainers.Pulsar.Tests/Testcontainers.Pulsar.Tests.csproj @@ -5,13 +5,13 @@ false - + - + diff --git a/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs b/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs index d745848d2..24e663049 100644 --- a/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs +++ b/tests/Testcontainers.RabbitMq.Tests/RabbitMqContainerTest.cs @@ -2,7 +2,7 @@ namespace Testcontainers.RabbitMq; public sealed class RabbitMqContainerTest : IAsyncLifetime { - // UseRabbitMqContainer { + // # --8<-- [start:UseRabbitMqContainer] private readonly RabbitMqContainer _rabbitMqContainer = new RabbitMqBuilder().Build(); public Task InitializeAsync() @@ -29,5 +29,5 @@ public void IsOpenReturnsTrue() // Then Assert.True(connection.IsOpen); } - // } + // # --8<-- [end:UseRabbitMqContainer] } \ No newline at end of file diff --git a/tests/Testcontainers.RabbitMq.Tests/Testcontainers.RabbitMq.Tests.csproj b/tests/Testcontainers.RabbitMq.Tests/Testcontainers.RabbitMq.Tests.csproj index 71fd05fb9..d6037faeb 100644 --- a/tests/Testcontainers.RabbitMq.Tests/Testcontainers.RabbitMq.Tests.csproj +++ b/tests/Testcontainers.RabbitMq.Tests/Testcontainers.RabbitMq.Tests.csproj @@ -5,13 +5,13 @@ false - + - +