From 8cad0fb19c7ab2b462bae0822a2b47881513b1c1 Mon Sep 17 00:00:00 2001 From: "Hamilton, Montane" Date: Thu, 10 Oct 2024 11:25:38 -0600 Subject: [PATCH 1/4] Add Seq Module --- .github/workflows/cicd.yml | 1 + Directory.Packages.props | 3 + Testcontainers.sln | 23 +++++- src/Testcontainers.Seq/.editorconfig | 1 + src/Testcontainers.Seq/SeqBuilder.cs | 72 +++++++++++++++++++ src/Testcontainers.Seq/SeqConfiguration.cs | 56 +++++++++++++++ src/Testcontainers.Seq/SeqContainer.cs | 22 ++++++ .../Testcontainers.Seq.csproj | 12 ++++ src/Testcontainers.Seq/Usings.cs | 6 ++ .../Testcontainers.Databases.Tests.csproj | 58 +++++++++++++-- tests/Testcontainers.Seq.Tests/.editorconfig | 1 + .../SeqContainerTest.cs | 38 ++++++++++ .../Testcontainers.Seq.Tests.csproj | 26 +++++++ tests/Testcontainers.Seq.Tests/Usings.cs | 3 + 14 files changed, 313 insertions(+), 9 deletions(-) create mode 100644 src/Testcontainers.Seq/.editorconfig create mode 100644 src/Testcontainers.Seq/SeqBuilder.cs create mode 100644 src/Testcontainers.Seq/SeqConfiguration.cs create mode 100644 src/Testcontainers.Seq/SeqContainer.cs create mode 100644 src/Testcontainers.Seq/Testcontainers.Seq.csproj create mode 100644 src/Testcontainers.Seq/Usings.cs create mode 100644 tests/Testcontainers.Seq.Tests/.editorconfig create mode 100644 tests/Testcontainers.Seq.Tests/SeqContainerTest.cs create mode 100644 tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj create mode 100644 tests/Testcontainers.Seq.Tests/Usings.cs diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 036861069..45542b95d 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -78,6 +78,7 @@ jobs: { name: "Testcontainers.RavenDb", runs-on: "ubuntu-22.04" }, { name: "Testcontainers.Redis", runs-on: "ubuntu-22.04" }, { name: "Testcontainers.Redpanda", runs-on: "ubuntu-22.04" }, + { name: "Testcontainers.Seq", runs-on: "ubuntu-22.04" }, { name: "Testcontainers.WebDriver", runs-on: "ubuntu-22.04" }, { name: "Testcontainers.Xunit", runs-on: "ubuntu-22.04" } ] diff --git a/Directory.Packages.props b/Directory.Packages.props index 813d398cf..004f60648 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,6 +9,7 @@ + @@ -23,6 +24,8 @@ + + diff --git a/Testcontainers.sln b/Testcontainers.sln index 1caef1ce5..6cbd1c779 100644 --- a/Testcontainers.sln +++ b/Testcontainers.sln @@ -201,14 +201,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.WebDriver.Te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Xunit.Tests", "tests\Testcontainers.Xunit.Tests\Testcontainers.Xunit.Tests.csproj", "{E901DF14-6F05-4FC2-825A-3055FAD33561}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Seq", "..\testcontainers-dotnet\src\Testcontainers.Seq\Testcontainers.Seq.csproj", "{F148CB77-9438-9DCF-CA37-75F7BCD5FEF6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Seq.Tests", "..\testcontainers-dotnet\tests\Testcontainers.Seq.Tests\Testcontainers.Seq.Tests.csproj", "{6FF86CD0-3801-ADE4-A59B-271AC8B2390C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {5365F780-0E6C-41F0-B1B9-7DC34368F80C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5365F780-0E6C-41F0-B1B9-7DC34368F80C}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -586,6 +587,17 @@ Global {E901DF14-6F05-4FC2-825A-3055FAD33561}.Debug|Any CPU.Build.0 = Debug|Any CPU {E901DF14-6F05-4FC2-825A-3055FAD33561}.Release|Any CPU.ActiveCfg = Release|Any CPU {E901DF14-6F05-4FC2-825A-3055FAD33561}.Release|Any CPU.Build.0 = Release|Any CPU + {F148CB77-9438-9DCF-CA37-75F7BCD5FEF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F148CB77-9438-9DCF-CA37-75F7BCD5FEF6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F148CB77-9438-9DCF-CA37-75F7BCD5FEF6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F148CB77-9438-9DCF-CA37-75F7BCD5FEF6}.Release|Any CPU.Build.0 = Release|Any CPU + {6FF86CD0-3801-ADE4-A59B-271AC8B2390C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6FF86CD0-3801-ADE4-A59B-271AC8B2390C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6FF86CD0-3801-ADE4-A59B-271AC8B2390C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6FF86CD0-3801-ADE4-A59B-271AC8B2390C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {5365F780-0E6C-41F0-B1B9-7DC34368F80C} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} @@ -682,5 +694,10 @@ Global {27CDB869-A150-4593-958F-6F26E5391E7C} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {E901DF14-6F05-4FC2-825A-3055FAD33561} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} + {F148CB77-9438-9DCF-CA37-75F7BCD5FEF6} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} + {6FF86CD0-3801-ADE4-A59B-271AC8B2390C} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5EC93352-CD4F-4CB4-84D3-B822DB932443} EndGlobalSection EndGlobal diff --git a/src/Testcontainers.Seq/.editorconfig b/src/Testcontainers.Seq/.editorconfig new file mode 100644 index 000000000..6f066619d --- /dev/null +++ b/src/Testcontainers.Seq/.editorconfig @@ -0,0 +1 @@ +root = true \ No newline at end of file diff --git a/src/Testcontainers.Seq/SeqBuilder.cs b/src/Testcontainers.Seq/SeqBuilder.cs new file mode 100644 index 000000000..e0648c85f --- /dev/null +++ b/src/Testcontainers.Seq/SeqBuilder.cs @@ -0,0 +1,72 @@ +namespace Testcontainers.Seq; + +/// +[PublicAPI] +public sealed class SeqBuilder : ContainerBuilder +{ + public const string SeqImage = "datalust/seq:2024.2.11456"; + + public const ushort SeqApiPort = 80; + public const ushort SeqIngestionPort = 5341; + + /// + protected override SeqConfiguration DockerResourceConfiguration { get; } + + /// + /// Initializes a new instance of the class. + /// + public SeqBuilder() + : this(new SeqConfiguration()) + { + DockerResourceConfiguration = Init().DockerResourceConfiguration; + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + private SeqBuilder(SeqConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + DockerResourceConfiguration = resourceConfiguration; + } + + /// + public override SeqContainer Build() + { + Validate(); + return new SeqContainer(DockerResourceConfiguration); + } + /// + protected override SeqBuilder Init() + { + return base.Init() + .WithImage(SeqImage) + .WithPortBinding(SeqApiPort, true) + .WithPortBinding(SeqIngestionPort, true) + .WithEnvironment(new Dictionary + { + {"ACCEPT_EULA", "Y" } + }) + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => + request.ForPath("/health").ForPort(SeqApiPort))); + } + + /// + protected override SeqBuilder Clone(IResourceConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new SeqConfiguration(resourceConfiguration)); + } + + /// + protected override SeqBuilder Clone(IContainerConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new SeqConfiguration(resourceConfiguration)); + } + + /// + protected override SeqBuilder Merge(SeqConfiguration oldValue, SeqConfiguration newValue) + { + return new SeqBuilder(new SeqConfiguration(oldValue, newValue)); + } +} \ No newline at end of file diff --git a/src/Testcontainers.Seq/SeqConfiguration.cs b/src/Testcontainers.Seq/SeqConfiguration.cs new file mode 100644 index 000000000..3302aa1e9 --- /dev/null +++ b/src/Testcontainers.Seq/SeqConfiguration.cs @@ -0,0 +1,56 @@ +namespace Testcontainers.Seq; + +/// +[PublicAPI] +public sealed class SeqConfiguration : ContainerConfiguration +{ + /// + /// Initializes a new instance of the class. + /// + /// The Orion.TestContainers.Seq config. + public SeqConfiguration(object config = null) + { + // Sets the custom builder methods property values. + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + public SeqConfiguration(IResourceConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + // Passes the configuration upwards to the base implementations to create an updated immutable copy. + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + public SeqConfiguration(IContainerConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + // Passes the configuration upwards to the base implementations to create an updated immutable copy. + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + public SeqConfiguration(SeqConfiguration resourceConfiguration) + : this(new SeqConfiguration(), resourceConfiguration) + { + // Passes the configuration upwards to the base implementations to create an updated immutable copy. + } + + /// + /// Initializes a new instance of the class. + /// + /// The old Docker resource configuration. + /// The new Docker resource configuration. + public SeqConfiguration(SeqConfiguration oldValue, SeqConfiguration newValue) + : base(oldValue, newValue) + { + // Create an updated immutable copy of the module configuration. + } +} \ No newline at end of file diff --git a/src/Testcontainers.Seq/SeqContainer.cs b/src/Testcontainers.Seq/SeqContainer.cs new file mode 100644 index 000000000..befc9850a --- /dev/null +++ b/src/Testcontainers.Seq/SeqContainer.cs @@ -0,0 +1,22 @@ +using System; + +namespace Testcontainers.Seq; + +/// +[PublicAPI] +public sealed class SeqContainer : DockerContainer +{ + /// + /// Initializes a new instance of the class. + /// + /// The container configuration. + public SeqContainer(SeqConfiguration configuration) + : base(configuration) + { + } + + public string GetServerApiUrl() + { + return new UriBuilder("http", Hostname, GetMappedPublicPort(SeqBuilder.SeqApiPort)).Uri.ToString(); + } +} \ No newline at end of file diff --git a/src/Testcontainers.Seq/Testcontainers.Seq.csproj b/src/Testcontainers.Seq/Testcontainers.Seq.csproj new file mode 100644 index 000000000..8b2ed72c6 --- /dev/null +++ b/src/Testcontainers.Seq/Testcontainers.Seq.csproj @@ -0,0 +1,12 @@ + + + net6.0;net8.0;netstandard2.0;netstandard2.1 + latest + + + + + + + + \ No newline at end of file diff --git a/src/Testcontainers.Seq/Usings.cs b/src/Testcontainers.Seq/Usings.cs new file mode 100644 index 000000000..080580c42 --- /dev/null +++ b/src/Testcontainers.Seq/Usings.cs @@ -0,0 +1,6 @@ +global using System.Collections.Generic; +global using Docker.DotNet.Models; +global using DotNet.Testcontainers.Builders; +global using DotNet.Testcontainers.Configurations; +global using DotNet.Testcontainers.Containers; +global using JetBrains.Annotations; diff --git a/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj b/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj index 2ca23a8cb..a5f13fc67 100644 --- a/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj +++ b/tests/Testcontainers.Databases.Tests/Testcontainers.Databases.Tests.csproj @@ -5,13 +5,59 @@ false - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/.editorconfig b/tests/Testcontainers.Seq.Tests/.editorconfig new file mode 100644 index 000000000..6f066619d --- /dev/null +++ b/tests/Testcontainers.Seq.Tests/.editorconfig @@ -0,0 +1 @@ +root = true \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs b/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs new file mode 100644 index 000000000..ed30ff6e9 --- /dev/null +++ b/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs @@ -0,0 +1,38 @@ +using Microsoft.Extensions.Logging; +using Seq.Api; +using System; +using System.Linq; + +namespace Testcontainers.Seq; + +public sealed class SeqContainerTest : IAsyncLifetime +{ + private readonly SeqContainer _seqContainer = new SeqBuilder().Build(); + + public Task InitializeAsync() + { + return _seqContainer.StartAsync(); + } + + public Task DisposeAsync() + { + return _seqContainer.DisposeAsync().AsTask(); + } + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public async Task CanLog() + { + var currentSeqApiPort = _seqContainer.GetMappedPublicPort(80); + var currentSeqHostname = _seqContainer.Hostname; + + ILoggerFactory loggerFactory = new LoggerFactory(); + loggerFactory.AddSeq(_seqContainer.GetServerApiUrl()); + var testLogger = loggerFactory.CreateLogger("testlogger"); + testLogger.LogInformation("TRY THIS"); + + var seqConnection = new SeqConnection(_seqContainer.GetServerApiUrl()); + var eventList = await seqConnection.Events.ListAsync(fromDateUtc: DateTime.Now.AddMinutes(-1)); + Assert.Contains(eventList, e => e.MessageTemplateTokens.Last().Text == "TRY THIS"); + } +} \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj b/tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj new file mode 100644 index 000000000..4ea635b58 --- /dev/null +++ b/tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj @@ -0,0 +1,26 @@ + + + net8.0 + false + false + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/Usings.cs b/tests/Testcontainers.Seq.Tests/Usings.cs new file mode 100644 index 000000000..346085388 --- /dev/null +++ b/tests/Testcontainers.Seq.Tests/Usings.cs @@ -0,0 +1,3 @@ +global using System.Threading.Tasks; +global using DotNet.Testcontainers.Commons; +global using Xunit; \ No newline at end of file From 5e215f6cef534dda6208322b20d9a71aeee1537b Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:24:40 +0100 Subject: [PATCH 2/4] chore(Seq): Update to recent repo standards --- Directory.Packages.props | 4 +- Testcontainers.sln | 30 +++---- Testcontainers.slnx | 2 + src/Testcontainers.Seq/SeqBuilder.cs | 85 +++++++++++++++---- src/Testcontainers.Seq/SeqConfiguration.cs | 5 +- .../SeqConnectionStringProvider.cs | 13 +++ src/Testcontainers.Seq/SeqContainer.cs | 10 ++- .../Testcontainers.Seq.csproj | 2 +- src/Testcontainers.Seq/Usings.cs | 6 +- .../DeclineLicenseAgreementTest.cs | 23 +++++ .../Testcontainers.EventHubs.Tests/Usings.cs | 1 + tests/Testcontainers.Seq.Tests/.runs-on | 1 + .../DeclineLicenseAgreementTest.cs | 23 +++++ tests/Testcontainers.Seq.Tests/Dockerfile | 1 + .../SeqContainerTest.cs | 45 +++++----- .../Testcontainers.Seq.Tests.csproj | 33 ++++--- tests/Testcontainers.Seq.Tests/Usings.cs | 7 +- 17 files changed, 209 insertions(+), 82 deletions(-) create mode 100644 src/Testcontainers.Seq/SeqConnectionStringProvider.cs create mode 100644 tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs create mode 100644 tests/Testcontainers.Seq.Tests/.runs-on create mode 100644 tests/Testcontainers.Seq.Tests/DeclineLicenseAgreementTest.cs create mode 100644 tests/Testcontainers.Seq.Tests/Dockerfile diff --git a/Directory.Packages.props b/Directory.Packages.props index d26cdf1f5..c2bdd7336 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -89,8 +89,8 @@ - - + + diff --git a/Testcontainers.sln b/Testcontainers.sln index 7e2cf18d9..2ebe217c0 100644 --- a/Testcontainers.sln +++ b/Testcontainers.sln @@ -1,4 +1,4 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 @@ -124,6 +124,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Redis", "src EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Redpanda", "src\Testcontainers.Redpanda\Testcontainers.Redpanda.csproj", "{45D6F69C-4D87-4130-AA90-0DB2F7460DAE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Seq", "src\Testcontainers.Seq\Testcontainers.Seq.csproj", "{EB246B55-788B-4B58-8739-994A66F91C8A}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.ServiceBus", "src\Testcontainers.ServiceBus\Testcontainers.ServiceBus.csproj", "{2E39E532-B81E-4B48-A004-FAE18EDF9E79}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Sftp", "src\Testcontainers.Sftp\Testcontainers.Sftp.csproj", "{7D5C6816-0DD2-4E13-A585-033B5D3C80D5}" @@ -264,6 +266,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Redpanda.Tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.ResourceReaper.Tests", "tests\Testcontainers.ResourceReaper.Tests\Testcontainers.ResourceReaper.Tests.csproj", "{9E8E6AA5-65D1-498F-BEAB-BA34723A0050}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Seq.Tests", "tests\Testcontainers.Seq.Tests\Testcontainers.Seq.Tests.csproj", "{4EFC0DFB-9F04-4070-848A-856D2F11C1BC}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.ServiceBus.Tests", "tests\Testcontainers.ServiceBus.Tests\Testcontainers.ServiceBus.Tests.csproj", "{232DD918-46ED-4BA8-B383-1A9146D83064}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Sftp.Tests", "tests\Testcontainers.Sftp.Tests\Testcontainers.Sftp.Tests.csproj", "{B73C3CC0-9F16-4B34-92BE-6EC0853912C5}" @@ -284,10 +288,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Xunit.Tests" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.XunitV3.Tests", "tests\Testcontainers.XunitV3.Tests\Testcontainers.XunitV3.Tests.csproj", "{B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Seq", "src\Testcontainers.Seq\Testcontainers.Seq.csproj", "{EB246B55-788B-4B58-8739-994A66F91C8A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Seq.Tests", "tests\Testcontainers.Seq.Tests\Testcontainers.Seq.Tests.csproj", "{4EFC0DFB-9F04-4070-848A-856D2F11C1BC}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -502,6 +502,10 @@ Global {45D6F69C-4D87-4130-AA90-0DB2F7460DAE}.Debug|Any CPU.Build.0 = Debug|Any CPU {45D6F69C-4D87-4130-AA90-0DB2F7460DAE}.Release|Any CPU.ActiveCfg = Release|Any CPU {45D6F69C-4D87-4130-AA90-0DB2F7460DAE}.Release|Any CPU.Build.0 = Release|Any CPU + {EB246B55-788B-4B58-8739-994A66F91C8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB246B55-788B-4B58-8739-994A66F91C8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB246B55-788B-4B58-8739-994A66F91C8A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB246B55-788B-4B58-8739-994A66F91C8A}.Release|Any CPU.Build.0 = Release|Any CPU {2E39E532-B81E-4B48-A004-FAE18EDF9E79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E39E532-B81E-4B48-A004-FAE18EDF9E79}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E39E532-B81E-4B48-A004-FAE18EDF9E79}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -782,6 +786,10 @@ Global {9E8E6AA5-65D1-498F-BEAB-BA34723A0050}.Debug|Any CPU.Build.0 = Debug|Any CPU {9E8E6AA5-65D1-498F-BEAB-BA34723A0050}.Release|Any CPU.ActiveCfg = Release|Any CPU {9E8E6AA5-65D1-498F-BEAB-BA34723A0050}.Release|Any CPU.Build.0 = Release|Any CPU + {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Release|Any CPU.Build.0 = Release|Any CPU {232DD918-46ED-4BA8-B383-1A9146D83064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {232DD918-46ED-4BA8-B383-1A9146D83064}.Debug|Any CPU.Build.0 = Debug|Any CPU {232DD918-46ED-4BA8-B383-1A9146D83064}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -822,14 +830,6 @@ Global {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}.Release|Any CPU.ActiveCfg = Release|Any CPU {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB}.Release|Any CPU.Build.0 = Release|Any CPU - {EB246B55-788B-4B58-8739-994A66F91C8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EB246B55-788B-4B58-8739-994A66F91C8A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EB246B55-788B-4B58-8739-994A66F91C8A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EB246B55-788B-4B58-8739-994A66F91C8A}.Release|Any CPU.Build.0 = Release|Any CPU - {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4EFC0DFB-9F04-4070-848A-856D2F11C1BC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -888,6 +888,7 @@ Global {F6394475-D6F1-46E2-81BF-4BA78A40B878} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {BFDA179A-40EB-4CEB-B8E9-0DF32C65E2C5} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {45D6F69C-4D87-4130-AA90-0DB2F7460DAE} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} + {EB246B55-788B-4B58-8739-994A66F91C8A} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {2E39E532-B81E-4B48-A004-FAE18EDF9E79} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {7D5C6816-0DD2-4E13-A585-033B5D3C80D5} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {24431BF1-7BEB-4C53-BAE8-B9D9F622A240} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} @@ -958,6 +959,7 @@ Global {31EE94A0-E721-4073-B6F1-DD912D004DEF} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {867BD04E-4670-4FBA-98D5-9F83220E6DFB} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {9E8E6AA5-65D1-498F-BEAB-BA34723A0050} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} + {4EFC0DFB-9F04-4070-848A-856D2F11C1BC} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {232DD918-46ED-4BA8-B383-1A9146D83064} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {B73C3CC0-9F16-4B34-92BE-6EC0853912C5} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {28B5DEDF-C19B-4A7E-B276-FC4C83DBB7EF} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} @@ -968,7 +970,5 @@ Global {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {E901DF14-6F05-4FC2-825A-3055FAD33561} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {B2E8B7FB-7D1E-4DD3-A25E-34DE4386B1EB} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} - {EB246B55-788B-4B58-8739-994A66F91C8A} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} - {4EFC0DFB-9F04-4070-848A-856D2F11C1BC} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} EndGlobalSection EndGlobal diff --git a/Testcontainers.slnx b/Testcontainers.slnx index e6a84283a..abe3157cf 100644 --- a/Testcontainers.slnx +++ b/Testcontainers.slnx @@ -62,6 +62,7 @@ + @@ -134,6 +135,7 @@ + diff --git a/src/Testcontainers.Seq/SeqBuilder.cs b/src/Testcontainers.Seq/SeqBuilder.cs index e0648c85f..eb694762f 100644 --- a/src/Testcontainers.Seq/SeqBuilder.cs +++ b/src/Testcontainers.Seq/SeqBuilder.cs @@ -4,21 +4,49 @@ namespace Testcontainers.Seq; [PublicAPI] public sealed class SeqBuilder : ContainerBuilder { - public const string SeqImage = "datalust/seq:2024.2.11456"; + public const string SeqImage = "datalust/seq:2025.2"; - public const ushort SeqApiPort = 80; - public const ushort SeqIngestionPort = 5341; - - /// - protected override SeqConfiguration DockerResourceConfiguration { get; } + public const ushort SeqPort = 80; /// /// Initializes a new instance of the class. /// + [Obsolete("This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.")] + [ExcludeFromCodeCoverage] public SeqBuilder() + : this(SeqImage) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The full Docker image name, including the image repository and tag + /// (e.g., datalust/seq:2025.2). + /// + /// + /// Docker image tags available at . + /// + public SeqBuilder(string image) + : this(new DockerImage(image)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// An instance that specifies the Docker image to be used + /// for the container builder configuration. + /// + /// + /// Docker image tags available at . + /// + public SeqBuilder(IImage image) : this(new SeqConfiguration()) { - DockerResourceConfiguration = Init().DockerResourceConfiguration; + DockerResourceConfiguration = Init().WithImage(image).DockerResourceConfiguration; } /// @@ -31,25 +59,50 @@ private SeqBuilder(SeqConfiguration resourceConfiguration) DockerResourceConfiguration = resourceConfiguration; } + /// + protected override SeqConfiguration DockerResourceConfiguration { get; } + + /// + protected override string AcceptLicenseAgreementEnvVar { get; } = "ACCEPT_EULA"; + + /// + protected override string AcceptLicenseAgreement { get; } = "Y"; + + /// + protected override string DeclineLicenseAgreement { get; } = "N"; + + /// + /// Accepts the license agreement. + /// + /// + /// When is set to true, the Seq license is accepted. + /// + /// A boolean value indicating whether the Seq license agreement is accepted. + /// A configured instance of . + public override SeqBuilder WithAcceptLicenseAgreement(bool acceptLicenseAgreement) + { + var licenseAgreement = acceptLicenseAgreement ? AcceptLicenseAgreement : DeclineLicenseAgreement; + return WithEnvironment(AcceptLicenseAgreementEnvVar, licenseAgreement); + } + /// public override SeqContainer Build() { Validate(); + ValidateLicenseAgreement(); + return new SeqContainer(DockerResourceConfiguration); } + /// protected override SeqBuilder Init() { return base.Init() - .WithImage(SeqImage) - .WithPortBinding(SeqApiPort, true) - .WithPortBinding(SeqIngestionPort, true) - .WithEnvironment(new Dictionary - { - {"ACCEPT_EULA", "Y" } - }) - .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => - request.ForPath("/health").ForPort(SeqApiPort))); + .WithPortBinding(SeqPort, true) + .WithEnvironment("SEQ_FIRSTRUN_NOAUTHENTICATION", "true") + .WithConnectionStringProvider(new SeqConnectionStringProvider()) + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => + request.ForPort(SeqPort).ForPath("/health"))); } /// diff --git a/src/Testcontainers.Seq/SeqConfiguration.cs b/src/Testcontainers.Seq/SeqConfiguration.cs index 3302aa1e9..144a6e097 100644 --- a/src/Testcontainers.Seq/SeqConfiguration.cs +++ b/src/Testcontainers.Seq/SeqConfiguration.cs @@ -7,10 +7,8 @@ public sealed class SeqConfiguration : ContainerConfiguration /// /// Initializes a new instance of the class. /// - /// The Orion.TestContainers.Seq config. - public SeqConfiguration(object config = null) + public SeqConfiguration() { - // Sets the custom builder methods property values. } /// @@ -51,6 +49,5 @@ public SeqConfiguration(SeqConfiguration resourceConfiguration) public SeqConfiguration(SeqConfiguration oldValue, SeqConfiguration newValue) : base(oldValue, newValue) { - // Create an updated immutable copy of the module configuration. } } \ No newline at end of file diff --git a/src/Testcontainers.Seq/SeqConnectionStringProvider.cs b/src/Testcontainers.Seq/SeqConnectionStringProvider.cs new file mode 100644 index 000000000..03ac502a6 --- /dev/null +++ b/src/Testcontainers.Seq/SeqConnectionStringProvider.cs @@ -0,0 +1,13 @@ +namespace Testcontainers.Seq; + +/// +/// Provides the Redpanda connection string. +/// +internal sealed class SeqConnectionStringProvider : ContainerConnectionStringProvider +{ + /// + protected override string GetHostConnectionString() + { + return Container.GetEndpoint(); + } +} \ No newline at end of file diff --git a/src/Testcontainers.Seq/SeqContainer.cs b/src/Testcontainers.Seq/SeqContainer.cs index befc9850a..c3a931d2d 100644 --- a/src/Testcontainers.Seq/SeqContainer.cs +++ b/src/Testcontainers.Seq/SeqContainer.cs @@ -1,5 +1,3 @@ -using System; - namespace Testcontainers.Seq; /// @@ -15,8 +13,12 @@ public SeqContainer(SeqConfiguration configuration) { } - public string GetServerApiUrl() + /// + /// Gets the Seq endpoint. + /// + /// The Seq endpoint. + public string GetEndpoint() { - return new UriBuilder("http", Hostname, GetMappedPublicPort(SeqBuilder.SeqApiPort)).Uri.ToString(); + return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(SeqBuilder.SeqPort)).ToString(); } } \ No newline at end of file diff --git a/src/Testcontainers.Seq/Testcontainers.Seq.csproj b/src/Testcontainers.Seq/Testcontainers.Seq.csproj index 8b2ed72c6..6f204b739 100644 --- a/src/Testcontainers.Seq/Testcontainers.Seq.csproj +++ b/src/Testcontainers.Seq/Testcontainers.Seq.csproj @@ -1,6 +1,6 @@ - net6.0;net8.0;netstandard2.0;netstandard2.1 + net8.0;net9.0;net10.0;netstandard2.0;netstandard2.1 latest diff --git a/src/Testcontainers.Seq/Usings.cs b/src/Testcontainers.Seq/Usings.cs index 080580c42..9bd35674e 100644 --- a/src/Testcontainers.Seq/Usings.cs +++ b/src/Testcontainers.Seq/Usings.cs @@ -1,6 +1,8 @@ -global using System.Collections.Generic; +global using System; +global using System.Diagnostics.CodeAnalysis; global using Docker.DotNet.Models; global using DotNet.Testcontainers.Builders; global using DotNet.Testcontainers.Configurations; global using DotNet.Testcontainers.Containers; -global using JetBrains.Annotations; +global using DotNet.Testcontainers.Images; +global using JetBrains.Annotations; \ No newline at end of file diff --git a/tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs b/tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs new file mode 100644 index 000000000..146677cf4 --- /dev/null +++ b/tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs @@ -0,0 +1,23 @@ +namespace Testcontainers.EventHubs; + +public sealed partial class DeclineLicenseAgreementTest +{ + [GeneratedRegex("The image '.+' requires you to accept a license agreement\\.")] + private static partial Regex LicenseAgreementNotAccepted(); + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public void WithoutAcceptingLicenseAgreementThrowsArgumentException() + { + var exception = Assert.Throws(() => new EventHubsBuilder(TestSession.GetImageFromDockerfile()).Build()); + Assert.Matches(LicenseAgreementNotAccepted(), exception.Message); + } + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public void WithLicenseAgreementDeclinedThrowsArgumentException() + { + var exception = Assert.Throws(() => new EventHubsBuilder(TestSession.GetImageFromDockerfile()).WithAcceptLicenseAgreement(false).Build()); + Assert.Matches(LicenseAgreementNotAccepted(), exception.Message); + } +} \ No newline at end of file diff --git a/tests/Testcontainers.EventHubs.Tests/Usings.cs b/tests/Testcontainers.EventHubs.Tests/Usings.cs index 39f6fba40..df238ff8d 100644 --- a/tests/Testcontainers.EventHubs.Tests/Usings.cs +++ b/tests/Testcontainers.EventHubs.Tests/Usings.cs @@ -1,5 +1,6 @@ global using System; global using System.Text; +global using System.Text.RegularExpressions; global using System.Threading.Tasks; global using Azure.Messaging.EventHubs; global using Azure.Messaging.EventHubs.Consumer; diff --git a/tests/Testcontainers.Seq.Tests/.runs-on b/tests/Testcontainers.Seq.Tests/.runs-on new file mode 100644 index 000000000..d0395e498 --- /dev/null +++ b/tests/Testcontainers.Seq.Tests/.runs-on @@ -0,0 +1 @@ +ubuntu-24.04 \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/DeclineLicenseAgreementTest.cs b/tests/Testcontainers.Seq.Tests/DeclineLicenseAgreementTest.cs new file mode 100644 index 000000000..59829ad55 --- /dev/null +++ b/tests/Testcontainers.Seq.Tests/DeclineLicenseAgreementTest.cs @@ -0,0 +1,23 @@ +namespace Testcontainers.Seq; + +public sealed partial class DeclineLicenseAgreementTest +{ + [GeneratedRegex("The image '.+' requires you to accept a license agreement\\.")] + private static partial Regex LicenseAgreementNotAccepted(); + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public void WithoutAcceptingLicenseAgreementThrowsArgumentException() + { + var exception = Assert.Throws(() => new SeqBuilder(TestSession.GetImageFromDockerfile()).Build()); + Assert.Matches(LicenseAgreementNotAccepted(), exception.Message); + } + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public void WithLicenseAgreementDeclinedThrowsArgumentException() + { + var exception = Assert.Throws(() => new SeqBuilder(TestSession.GetImageFromDockerfile()).WithAcceptLicenseAgreement(false).Build()); + Assert.Matches(LicenseAgreementNotAccepted(), exception.Message); + } +} \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/Dockerfile b/tests/Testcontainers.Seq.Tests/Dockerfile new file mode 100644 index 000000000..83f075b22 --- /dev/null +++ b/tests/Testcontainers.Seq.Tests/Dockerfile @@ -0,0 +1 @@ +FROM datalust/seq:2025.2 \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs b/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs index ed30ff6e9..b03fb0be1 100644 --- a/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs +++ b/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs @@ -1,38 +1,43 @@ -using Microsoft.Extensions.Logging; -using Seq.Api; -using System; -using System.Linq; - namespace Testcontainers.Seq; public sealed class SeqContainerTest : IAsyncLifetime { - private readonly SeqContainer _seqContainer = new SeqBuilder().Build(); + private readonly SeqContainer _seqContainer = new SeqBuilder(TestSession.GetImageFromDockerfile()).WithAcceptLicenseAgreement(true).Build(); - public Task InitializeAsync() + public async ValueTask InitializeAsync() { - return _seqContainer.StartAsync(); + await _seqContainer.StartAsync() + .ConfigureAwait(false); } - public Task DisposeAsync() + public ValueTask DisposeAsync() { - return _seqContainer.DisposeAsync().AsTask(); + return _seqContainer.DisposeAsync(); } [Fact] [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] - public async Task CanLog() + public async Task LogsMessageToSeq() { - var currentSeqApiPort = _seqContainer.GetMappedPublicPort(80); - var currentSeqHostname = _seqContainer.Hostname; + // Given + const string helloWorld = "Hello, World!"; + + var endpoint = _seqContainer.GetEndpoint(); + + var loggerFactory = new LoggerFactory(); + loggerFactory.AddSeq(endpoint); + + var logger = loggerFactory.CreateLogger(nameof(SeqContainerTest)); + logger.LogInformation(helloWorld); + + using var connection = new SeqConnection(endpoint); - ILoggerFactory loggerFactory = new LoggerFactory(); - loggerFactory.AddSeq(_seqContainer.GetServerApiUrl()); - var testLogger = loggerFactory.CreateLogger("testlogger"); - testLogger.LogInformation("TRY THIS"); + // When + var events = await connection.Events.ListAsync(cancellationToken: TestContext.Current.CancellationToken) + .ConfigureAwait(true); - var seqConnection = new SeqConnection(_seqContainer.GetServerApiUrl()); - var eventList = await seqConnection.Events.ListAsync(fromDateUtc: DateTime.Now.AddMinutes(-1)); - Assert.Contains(eventList, e => e.MessageTemplateTokens.Last().Text == "TRY THIS"); + // Then + Assert.Single(events); + Assert.Equal(helloWorld, events[0].MessageTemplateTokens.Last().Text); } } \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj b/tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj index 4ea635b58..af9a5ebbe 100644 --- a/tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj +++ b/tests/Testcontainers.Seq.Tests/Testcontainers.Seq.Tests.csproj @@ -1,26 +1,25 @@ - + - net8.0 + net10.0 false false + Exe - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + + + - - + + + + + + PreserveNewest + \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/Usings.cs b/tests/Testcontainers.Seq.Tests/Usings.cs index 346085388..6d8b85d27 100644 --- a/tests/Testcontainers.Seq.Tests/Usings.cs +++ b/tests/Testcontainers.Seq.Tests/Usings.cs @@ -1,3 +1,8 @@ global using System.Threading.Tasks; global using DotNet.Testcontainers.Commons; -global using Xunit; \ No newline at end of file +global using Xunit; +global using Microsoft.Extensions.Logging; +global using Seq.Api; +global using System; +global using System.Linq; +global using System.Text.RegularExpressions; \ No newline at end of file From 8296633411f02d5e46a46b83fe643effa3ad6fc4 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:46:07 +0100 Subject: [PATCH 3/4] fix(EventHubs): Configure builder correct --- .github/workflows/cicd.yml | 2 +- Directory.Packages.props | 2 +- .../SeqConnectionStringProvider.cs | 2 +- .../DeclineLicenseAgreementTest.cs | 13 +++++++++++-- tests/Testcontainers.Seq.Tests/Usings.cs | 8 ++++---- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e27b9c17a..be0d9538e 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -180,4 +180,4 @@ jobs: with: version: ${{ env.semVer }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Directory.Packages.props b/Directory.Packages.props index c2bdd7336..5e9236e5b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -95,4 +95,4 @@ - \ No newline at end of file + diff --git a/src/Testcontainers.Seq/SeqConnectionStringProvider.cs b/src/Testcontainers.Seq/SeqConnectionStringProvider.cs index 03ac502a6..9b5f6ea97 100644 --- a/src/Testcontainers.Seq/SeqConnectionStringProvider.cs +++ b/src/Testcontainers.Seq/SeqConnectionStringProvider.cs @@ -1,7 +1,7 @@ namespace Testcontainers.Seq; /// -/// Provides the Redpanda connection string. +/// Provides the Seq connection string. /// internal sealed class SeqConnectionStringProvider : ContainerConnectionStringProvider { diff --git a/tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs b/tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs index 146677cf4..6f476f042 100644 --- a/tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs +++ b/tests/Testcontainers.EventHubs.Tests/DeclineLicenseAgreementTest.cs @@ -2,6 +2,10 @@ namespace Testcontainers.EventHubs; public sealed partial class DeclineLicenseAgreementTest { + private const string EventHubsName = "eh-1"; + + private const string EventHubsConsumerGroupName = "cg-1"; + [GeneratedRegex("The image '.+' requires you to accept a license agreement\\.")] private static partial Regex LicenseAgreementNotAccepted(); @@ -9,7 +13,7 @@ public sealed partial class DeclineLicenseAgreementTest [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] public void WithoutAcceptingLicenseAgreementThrowsArgumentException() { - var exception = Assert.Throws(() => new EventHubsBuilder(TestSession.GetImageFromDockerfile()).Build()); + var exception = Assert.Throws(() => new EventHubsBuilder(TestSession.GetImageFromDockerfile()).WithConfigurationBuilder(GetServiceConfiguration()).Build()); Assert.Matches(LicenseAgreementNotAccepted(), exception.Message); } @@ -17,7 +21,12 @@ public void WithoutAcceptingLicenseAgreementThrowsArgumentException() [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] public void WithLicenseAgreementDeclinedThrowsArgumentException() { - var exception = Assert.Throws(() => new EventHubsBuilder(TestSession.GetImageFromDockerfile()).WithAcceptLicenseAgreement(false).Build()); + var exception = Assert.Throws(() => new EventHubsBuilder(TestSession.GetImageFromDockerfile()).WithAcceptLicenseAgreement(false).WithConfigurationBuilder(GetServiceConfiguration()).Build()); Assert.Matches(LicenseAgreementNotAccepted(), exception.Message); } + + private static EventHubsServiceConfiguration GetServiceConfiguration() + { + return EventHubsServiceConfiguration.Create().WithEntity(EventHubsName, 2, EventHubConsumerClient.DefaultConsumerGroupName, EventHubsConsumerGroupName); + } } \ No newline at end of file diff --git a/tests/Testcontainers.Seq.Tests/Usings.cs b/tests/Testcontainers.Seq.Tests/Usings.cs index 6d8b85d27..67ec661f5 100644 --- a/tests/Testcontainers.Seq.Tests/Usings.cs +++ b/tests/Testcontainers.Seq.Tests/Usings.cs @@ -1,8 +1,8 @@ +global using System; +global using System.Linq; +global using System.Text.RegularExpressions; global using System.Threading.Tasks; global using DotNet.Testcontainers.Commons; -global using Xunit; global using Microsoft.Extensions.Logging; global using Seq.Api; -global using System; -global using System.Linq; -global using System.Text.RegularExpressions; \ No newline at end of file +global using Xunit; \ No newline at end of file From ad4a4fd2b8f4af65109481f8c08557cb5896569b Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:01:44 +0100 Subject: [PATCH 4/4] chore: Apply code suggestions --- src/Testcontainers.Seq/SeqBuilder.cs | 2 +- tests/Testcontainers.Seq.Tests/SeqContainerTest.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Testcontainers.Seq/SeqBuilder.cs b/src/Testcontainers.Seq/SeqBuilder.cs index eb694762f..fca135508 100644 --- a/src/Testcontainers.Seq/SeqBuilder.cs +++ b/src/Testcontainers.Seq/SeqBuilder.cs @@ -78,7 +78,7 @@ private SeqBuilder(SeqConfiguration resourceConfiguration) /// When is set to true, the Seq license is accepted. /// /// A boolean value indicating whether the Seq license agreement is accepted. - /// A configured instance of . + /// A configured instance of . public override SeqBuilder WithAcceptLicenseAgreement(bool acceptLicenseAgreement) { var licenseAgreement = acceptLicenseAgreement ? AcceptLicenseAgreement : DeclineLicenseAgreement; diff --git a/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs b/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs index b03fb0be1..069a3f716 100644 --- a/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs +++ b/tests/Testcontainers.Seq.Tests/SeqContainerTest.cs @@ -30,6 +30,9 @@ public async Task LogsMessageToSeq() var logger = loggerFactory.CreateLogger(nameof(SeqContainerTest)); logger.LogInformation(helloWorld); + // Ensure pending messages are sent before querying. + loggerFactory.Dispose(); + using var connection = new SeqConnection(endpoint); // When