From 3ed5e18df22923fc710098882f967fc25f7ec38a Mon Sep 17 00:00:00 2001 From: Liam Wilson Date: Wed, 8 Nov 2023 17:01:47 +0000 Subject: [PATCH 1/7] Added Papercut module --- Testcontainers.sln | 14 ++++ src/Testcontainers.Papercut/.editorconfig | 1 + .../EmailAddressDetail.cs | 8 +++ src/Testcontainers.Papercut/HeaderDetail.cs | 8 +++ .../PapercutBuilder.cs | 71 +++++++++++++++++++ .../PapercutConfiguration.cs | 55 ++++++++++++++ .../PapercutContainer.cs | 39 ++++++++++ .../PapercutMessage.cs | 17 +++++ .../PapercutMessageCollection.cs | 8 +++ .../PapercutMessageSummary.cs | 10 +++ src/Testcontainers.Papercut/SectionDetail.cs | 9 +++ .../Testcontainers.Papercut.csproj | 18 +++++ src/Testcontainers.Papercut/Usings.cs | 8 +++ .../.editorconfig | 1 + .../PapercutContainerTest.cs | 40 +++++++++++ .../Testcontainers.Papercut.Tests.csproj | 17 +++++ tests/Testcontainers.Papercut.Tests/Usings.cs | 3 + 17 files changed, 327 insertions(+) create mode 100644 src/Testcontainers.Papercut/.editorconfig create mode 100644 src/Testcontainers.Papercut/EmailAddressDetail.cs create mode 100644 src/Testcontainers.Papercut/HeaderDetail.cs create mode 100644 src/Testcontainers.Papercut/PapercutBuilder.cs create mode 100644 src/Testcontainers.Papercut/PapercutConfiguration.cs create mode 100644 src/Testcontainers.Papercut/PapercutContainer.cs create mode 100644 src/Testcontainers.Papercut/PapercutMessage.cs create mode 100644 src/Testcontainers.Papercut/PapercutMessageCollection.cs create mode 100644 src/Testcontainers.Papercut/PapercutMessageSummary.cs create mode 100644 src/Testcontainers.Papercut/SectionDetail.cs create mode 100644 src/Testcontainers.Papercut/Testcontainers.Papercut.csproj create mode 100644 src/Testcontainers.Papercut/Usings.cs create mode 100644 tests/Testcontainers.Papercut.Tests/.editorconfig create mode 100644 tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs create mode 100644 tests/Testcontainers.Papercut.Tests/Testcontainers.Papercut.Tests.csproj create mode 100644 tests/Testcontainers.Papercut.Tests/Usings.cs diff --git a/Testcontainers.sln b/Testcontainers.sln index ac471c14e..b4e64b120 100644 --- a/Testcontainers.sln +++ b/Testcontainers.sln @@ -159,6 +159,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Tests", "tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.WebDriver.Tests", "tests\Testcontainers.WebDriver.Tests\Testcontainers.WebDriver.Tests.csproj", "{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Papercut", "src\Testcontainers.Papercut\Testcontainers.Papercut.csproj", "{464F1120-A0DA-462B-B9E8-45176D883625}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Papercut.Tests", "tests\Testcontainers.Papercut.Tests\Testcontainers.Papercut.Tests.csproj", "{904C8476-FCEF-41F0-8948-9EFA7C08712E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -460,6 +464,14 @@ Global {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Release|Any CPU.Build.0 = Release|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Debug|Any CPU.Build.0 = Debug|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Release|Any CPU.ActiveCfg = Release|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Release|Any CPU.Build.0 = Release|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {3F2E254F-C203-43FD-A078-DC3E2CBC0F9F} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} @@ -535,5 +547,7 @@ Global {1A1983E6-5297-435F-B467-E8E1F11277D6} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {27CDB869-A150-4593-958F-6F26E5391E7C} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} + {464F1120-A0DA-462B-B9E8-45176D883625} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} + {904C8476-FCEF-41F0-8948-9EFA7C08712E} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} EndGlobalSection EndGlobal diff --git a/src/Testcontainers.Papercut/.editorconfig b/src/Testcontainers.Papercut/.editorconfig new file mode 100644 index 000000000..6f066619d --- /dev/null +++ b/src/Testcontainers.Papercut/.editorconfig @@ -0,0 +1 @@ +root = true \ No newline at end of file diff --git a/src/Testcontainers.Papercut/EmailAddressDetail.cs b/src/Testcontainers.Papercut/EmailAddressDetail.cs new file mode 100644 index 000000000..59cd50f9b --- /dev/null +++ b/src/Testcontainers.Papercut/EmailAddressDetail.cs @@ -0,0 +1,8 @@ +namespace Testcontainers.Papercut +{ + public class EmailAddressDetail + { + public string Name { get; set; } + public string Address { get; set; } + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/HeaderDetail.cs b/src/Testcontainers.Papercut/HeaderDetail.cs new file mode 100644 index 000000000..5a00d9632 --- /dev/null +++ b/src/Testcontainers.Papercut/HeaderDetail.cs @@ -0,0 +1,8 @@ +namespace Testcontainers.Papercut +{ + public class HeaderDetail + { + public string Name { get; set; } + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutBuilder.cs b/src/Testcontainers.Papercut/PapercutBuilder.cs new file mode 100644 index 000000000..b83d16b0b --- /dev/null +++ b/src/Testcontainers.Papercut/PapercutBuilder.cs @@ -0,0 +1,71 @@ +using System.Net; + +namespace Testcontainers.Papercut; + +/// +[PublicAPI] +public sealed class PapercutBuilder : ContainerBuilder +{ + /// + /// Initializes a new instance of the class. + /// + public PapercutBuilder() + : this(new PapercutConfiguration()) + { + DockerResourceConfiguration = Init().DockerResourceConfiguration; + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + private PapercutBuilder(PapercutConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + DockerResourceConfiguration = resourceConfiguration; + } + + /// + protected override PapercutConfiguration DockerResourceConfiguration { get; } + + /// + public override PapercutContainer Build() + { + Validate(); + return new PapercutContainer(DockerResourceConfiguration, TestcontainersSettings.Logger); + } + + /// + protected override PapercutBuilder Init() + { + return base.Init() + .WithImage("jijiechen/papercut:latest") + .WithPortBinding(25,true) + .WithPortBinding(37408,true) + .WithWaitStrategy( + Wait.ForUnixContainer() + .UntilHttpRequestIsSucceeded(strategy => + { + return strategy.ForPort(37408).ForStatusCode(HttpStatusCode.OK); + }) + ); + } + + /// + protected override PapercutBuilder Clone(IResourceConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); + } + + /// + protected override PapercutBuilder Clone(IContainerConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); + } + + /// + protected override PapercutBuilder Merge(PapercutConfiguration oldValue, PapercutConfiguration newValue) + { + return new PapercutBuilder(new PapercutConfiguration(oldValue, newValue)); + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutConfiguration.cs b/src/Testcontainers.Papercut/PapercutConfiguration.cs new file mode 100644 index 000000000..b59f11465 --- /dev/null +++ b/src/Testcontainers.Papercut/PapercutConfiguration.cs @@ -0,0 +1,55 @@ +namespace Testcontainers.Papercut; + +/// +[PublicAPI] +public sealed class PapercutConfiguration : ContainerConfiguration +{ + /// + /// Initializes a new instance of the class. + /// + public PapercutConfiguration() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + public PapercutConfiguration(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 PapercutConfiguration(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 PapercutConfiguration(PapercutConfiguration resourceConfiguration) + : this(new PapercutConfiguration(), 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 PapercutConfiguration(PapercutConfiguration oldValue, PapercutConfiguration newValue) + : base(oldValue, newValue) + { + // // Create an updated immutable copy of the module configuration. + // Config = BuildConfiguration.Combine(oldValue.Config, newValue.Config); + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutContainer.cs b/src/Testcontainers.Papercut/PapercutContainer.cs new file mode 100644 index 000000000..f4c98c75b --- /dev/null +++ b/src/Testcontainers.Papercut/PapercutContainer.cs @@ -0,0 +1,39 @@ +using System.Net.Http; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace Testcontainers.Papercut; + +/// +[PublicAPI] +public sealed class PapercutContainer : DockerContainer +{ + /// + /// Initializes a new instance of the class. + /// + /// The container configuration. + /// The logger. + public PapercutContainer(PapercutConfiguration configuration, ILogger logger) + : base(configuration, logger) + { + } + + public string WebUrl => "http://" + Hostname + ":" + GetMappedPublicPort(37408); + + public async Task GetMessages() + { + var client = new HttpClient(); + client.BaseAddress = new Uri(WebUrl); + var messageText = await client.GetStringAsync("/api/messages"); + return JsonConvert.DeserializeObject(messageText); + } + + public async Task GetMessage(string id) + { + var client = new HttpClient(); + client.BaseAddress = new Uri(WebUrl); + var messageText = await client.GetStringAsync($"/api/messages/{id}"); + return JsonConvert.DeserializeObject(messageText); + } + +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutMessage.cs b/src/Testcontainers.Papercut/PapercutMessage.cs new file mode 100644 index 000000000..ac831ff38 --- /dev/null +++ b/src/Testcontainers.Papercut/PapercutMessage.cs @@ -0,0 +1,17 @@ +namespace Testcontainers.Papercut +{ + public class PapercutMessage + { + public string Id { get; set; } + public string Subject { get; set; } + public DateTime CreatedAt { get; set; } + public IEnumerable From { get; set; } + public IEnumerable To { get; set; } + public IEnumerable Cc { get; set; } + public IEnumerable BCc { get; set; } + [CanBeNull] public string HtmlBody { get; set; } + [CanBeNull] public string TextBody { get; set; } + public IEnumerable Headers { get; set; } + public IEnumerable Sections { get; set; } + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutMessageCollection.cs b/src/Testcontainers.Papercut/PapercutMessageCollection.cs new file mode 100644 index 000000000..92aa75f7d --- /dev/null +++ b/src/Testcontainers.Papercut/PapercutMessageCollection.cs @@ -0,0 +1,8 @@ +namespace Testcontainers.Papercut +{ + public class PapercutMessageCollection + { + public int TotalMessageCount { get; set; } + public IEnumerable Messages { get; set; } + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutMessageSummary.cs b/src/Testcontainers.Papercut/PapercutMessageSummary.cs new file mode 100644 index 000000000..02bbbee08 --- /dev/null +++ b/src/Testcontainers.Papercut/PapercutMessageSummary.cs @@ -0,0 +1,10 @@ +namespace Testcontainers.Papercut +{ + public class PapercutMessageSummary + { + public string Id { get; set; } + public string Subject { get; set; } + public string Size { get; set; } + public DateTime CreatedAt { get; set; } + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/SectionDetail.cs b/src/Testcontainers.Papercut/SectionDetail.cs new file mode 100644 index 000000000..b569e8e43 --- /dev/null +++ b/src/Testcontainers.Papercut/SectionDetail.cs @@ -0,0 +1,9 @@ +namespace Testcontainers.Papercut +{ + public class SectionDetail + { + public string Id { get; set; } + public string MediaType { get; set; } + public string FileName { get; set; } + } +} \ No newline at end of file diff --git a/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj b/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj new file mode 100644 index 000000000..4235a0201 --- /dev/null +++ b/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj @@ -0,0 +1,18 @@ + + + netstandard2.0;netstandard2.1 + latest + Liam Wilson, Andre Hofmeister and contributors + A testcontainer that setups Papercut SMTP + +Testcontainers for .NET is a library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions. + Copyright (c) 2019 - 2023 Liam Wilson, Andre Hofmeister and other authors + + + + + + + + + \ No newline at end of file diff --git a/src/Testcontainers.Papercut/Usings.cs b/src/Testcontainers.Papercut/Usings.cs new file mode 100644 index 000000000..2cc17791b --- /dev/null +++ b/src/Testcontainers.Papercut/Usings.cs @@ -0,0 +1,8 @@ +global using System; +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; +global using Microsoft.Extensions.Logging; \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/.editorconfig b/tests/Testcontainers.Papercut.Tests/.editorconfig new file mode 100644 index 000000000..6f066619d --- /dev/null +++ b/tests/Testcontainers.Papercut.Tests/.editorconfig @@ -0,0 +1 @@ +root = true \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs new file mode 100644 index 000000000..f8918ec6e --- /dev/null +++ b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs @@ -0,0 +1,40 @@ +using System.Linq; +using System.Net.Mail; + +namespace Testcontainers.Papercut; + +public sealed class PapercutContainerTest : IAsyncLifetime +{ + private readonly PapercutContainer _papercutContainer = new PapercutBuilder().Build(); + + public Task InitializeAsync() + { + return _papercutContainer.StartAsync(); + } + + public Task DisposeAsync() + { + return _papercutContainer.DisposeAsync().AsTask(); + } + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public async Task SendingAnEmail() + { + //Given + var client = new SmtpClient(_papercutContainer.Hostname,_papercutContainer.GetMappedPublicPort(25)); + + //When + client.Send("test@test.com","recipient@test.com","Test","A test message"); + await Task.Delay(25); + + //Then + var result = await _papercutContainer.GetMessages(); + Assert.Equal(1, result.TotalMessageCount); + var message = await _papercutContainer.GetMessage(result.Messages.Single().Id); + Assert.Equal("Test",message.Subject); + Assert.Equal("A test message\n",message.TextBody); + Assert.Equal("test@test.com",message.From.Single().Address); + Assert.Equal("recipient@test.com",message.To.Single().Address); + } +} \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/Testcontainers.Papercut.Tests.csproj b/tests/Testcontainers.Papercut.Tests/Testcontainers.Papercut.Tests.csproj new file mode 100644 index 000000000..d42adb2ec --- /dev/null +++ b/tests/Testcontainers.Papercut.Tests/Testcontainers.Papercut.Tests.csproj @@ -0,0 +1,17 @@ + + + net6.0 + false + false + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/Usings.cs b/tests/Testcontainers.Papercut.Tests/Usings.cs new file mode 100644 index 000000000..346085388 --- /dev/null +++ b/tests/Testcontainers.Papercut.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 f73272dc55989cf16b88be785ccc57c2984ec812 Mon Sep 17 00:00:00 2001 From: Liam Wilson Date: Wed, 8 Nov 2023 17:32:13 +0000 Subject: [PATCH 2/7] Improved unit test so its not time dependant but will still time out --- .../PapercutContainerTest.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs index f8918ec6e..182951d76 100644 --- a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs +++ b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using System.Linq; using System.Net.Mail; @@ -26,10 +27,16 @@ public async Task SendingAnEmail() //When client.Send("test@test.com","recipient@test.com","Test","A test message"); - await Task.Delay(25); - + //Then var result = await _papercutContainer.GetMessages(); + + var startTimeout = Stopwatch.StartNew(); + while (result.TotalMessageCount < 1 && startTimeout.Elapsed.TotalSeconds < 5) + { + result = await _papercutContainer.GetMessages(); + } + Assert.Equal(1, result.TotalMessageCount); var message = await _papercutContainer.GetMessage(result.Messages.Single().Id); Assert.Equal("Test",message.Subject); From 8a2153cff7f32b66eacf365b0d537b3c6500c526 Mon Sep 17 00:00:00 2001 From: Liam Wilson Date: Wed, 8 Nov 2023 20:17:04 +0000 Subject: [PATCH 3/7] Added the extra API calls --- .../PapercutContainer.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Testcontainers.Papercut/PapercutContainer.cs b/src/Testcontainers.Papercut/PapercutContainer.cs index f4c98c75b..b1470571f 100644 --- a/src/Testcontainers.Papercut/PapercutContainer.cs +++ b/src/Testcontainers.Papercut/PapercutContainer.cs @@ -1,3 +1,4 @@ +using System.IO; using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json; @@ -36,4 +37,41 @@ public async Task GetMessage(string id) return JsonConvert.DeserializeObject(messageText); } + public async Task DeleteMessages() + { + var client = new HttpClient(); + client.BaseAddress = new Uri(WebUrl); + var response = await client.DeleteAsync("/api/messages"); + return response.IsSuccessStatusCode; + } + + public async Task DeleteMessages(string id) + { + var client = new HttpClient(); + client.BaseAddress = new Uri(WebUrl); + var response = await client.DeleteAsync($"/api/messages/{id}"); + return response.IsSuccessStatusCode; + } + + public Task DownloadRaw(string id) + { + var client = new HttpClient(); + client.BaseAddress = new Uri(WebUrl); + return client.GetAsync($"/api/messages/{id}/raw"); + } + + public Task DownloadSection(string id, int index) + { + var client = new HttpClient(); + client.BaseAddress = new Uri(WebUrl); + return client.GetAsync($"/api/messages/{id}/sections/{index}"); + } + + public Task DownloadSectionContent(string id, string contentId) + { + var client = new HttpClient(); + client.BaseAddress = new Uri(WebUrl); + return client.GetAsync($"/api/messages/{id}/contents/{contentId}"); + } + } \ No newline at end of file From c3084d9a1458e7285abdb76259cc647dbef44ad2 Mon Sep 17 00:00:00 2001 From: Liam Wilson Date: Wed, 8 Nov 2023 20:17:45 +0000 Subject: [PATCH 4/7] Removed using that not needed --- src/Testcontainers.Papercut/PapercutContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Testcontainers.Papercut/PapercutContainer.cs b/src/Testcontainers.Papercut/PapercutContainer.cs index b1470571f..b408240fb 100644 --- a/src/Testcontainers.Papercut/PapercutContainer.cs +++ b/src/Testcontainers.Papercut/PapercutContainer.cs @@ -1,4 +1,3 @@ -using System.IO; using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json; From ba015dd3a03ab8e02ac73c67ec346e93c5e32250 Mon Sep 17 00:00:00 2001 From: Liam Wilson Date: Sun, 12 Nov 2023 17:13:01 +0000 Subject: [PATCH 5/7] Removed the client calls as this is out of scope for the package Moved client models to test project as this uses them but it not used in package project now Added constants for Port numbers Moved using statements to Usings.cs file Added delegate for getting public SMTP port number --- .../PapercutBuilder.cs | 124 +++++++++--------- .../PapercutConfiguration.cs | 95 +++++++------- .../PapercutContainer.cs | 90 +++---------- .../Testcontainers.Papercut.csproj | 3 +- src/Testcontainers.Papercut/Usings.cs | 5 +- .../EmailAddressDetail.cs | 0 .../HeaderDetail.cs | 0 .../PapercutContainerTest.cs | 17 +-- .../PapercutMessage.cs | 3 + .../PapercutMessageCollection.cs | 0 .../PapercutMessageSummary.cs | 0 .../SectionDetail.cs | 0 tests/Testcontainers.Papercut.Tests/Usings.cs | 11 +- 13 files changed, 154 insertions(+), 194 deletions(-) rename {src/Testcontainers.Papercut => tests/Testcontainers.Papercut.Tests}/EmailAddressDetail.cs (100%) rename {src/Testcontainers.Papercut => tests/Testcontainers.Papercut.Tests}/HeaderDetail.cs (100%) rename {src/Testcontainers.Papercut => tests/Testcontainers.Papercut.Tests}/PapercutMessage.cs (91%) rename {src/Testcontainers.Papercut => tests/Testcontainers.Papercut.Tests}/PapercutMessageCollection.cs (100%) rename {src/Testcontainers.Papercut => tests/Testcontainers.Papercut.Tests}/PapercutMessageSummary.cs (100%) rename {src/Testcontainers.Papercut => tests/Testcontainers.Papercut.Tests}/SectionDetail.cs (100%) diff --git a/src/Testcontainers.Papercut/PapercutBuilder.cs b/src/Testcontainers.Papercut/PapercutBuilder.cs index b83d16b0b..8c6636f8a 100644 --- a/src/Testcontainers.Papercut/PapercutBuilder.cs +++ b/src/Testcontainers.Papercut/PapercutBuilder.cs @@ -1,71 +1,75 @@ -using System.Net; - -namespace Testcontainers.Papercut; - -/// -[PublicAPI] -public sealed class PapercutBuilder : ContainerBuilder +namespace Testcontainers.Papercut { - /// - /// Initializes a new instance of the class. - /// - public PapercutBuilder() - : this(new PapercutConfiguration()) + /// + [PublicAPI] + public sealed class PapercutBuilder : ContainerBuilder { - DockerResourceConfiguration = Init().DockerResourceConfiguration; - } + private const string PapercutImage = "jijiechen/papercut:latest"; + internal const int SmtpPort = 25; + internal const int WebInterfacePort = 37408; - /// - /// Initializes a new instance of the class. - /// - /// The Docker resource configuration. - private PapercutBuilder(PapercutConfiguration resourceConfiguration) - : base(resourceConfiguration) - { - DockerResourceConfiguration = resourceConfiguration; - } + /// + /// Initializes a new instance of the class. + /// + public PapercutBuilder() + : this(new PapercutConfiguration()) + { + DockerResourceConfiguration = Init().DockerResourceConfiguration; + } - /// - protected override PapercutConfiguration DockerResourceConfiguration { get; } + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + private PapercutBuilder(PapercutConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + DockerResourceConfiguration = resourceConfiguration; + } - /// - public override PapercutContainer Build() - { - Validate(); - return new PapercutContainer(DockerResourceConfiguration, TestcontainersSettings.Logger); - } + /// + protected override PapercutConfiguration DockerResourceConfiguration { get; } - /// - protected override PapercutBuilder Init() - { - return base.Init() - .WithImage("jijiechen/papercut:latest") - .WithPortBinding(25,true) - .WithPortBinding(37408,true) - .WithWaitStrategy( - Wait.ForUnixContainer() - .UntilHttpRequestIsSucceeded(strategy => - { - return strategy.ForPort(37408).ForStatusCode(HttpStatusCode.OK); - }) - ); - } + /// + public override PapercutContainer Build() + { + Validate(); + return new PapercutContainer(DockerResourceConfiguration, TestcontainersSettings.Logger); + } - /// - protected override PapercutBuilder Clone(IResourceConfiguration resourceConfiguration) - { - return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); - } + /// + protected override PapercutBuilder Init() + { + return base.Init() + .WithImage(PapercutImage) + .WithPortBinding(SmtpPort, true) + .WithPortBinding(WebInterfacePort, true) + .WithWaitStrategy( + Wait.ForUnixContainer() + .UntilHttpRequestIsSucceeded(strategy => + { + return strategy.ForPort(WebInterfacePort).ForStatusCode(HttpStatusCode.OK); + }) + ); + } - /// - protected override PapercutBuilder Clone(IContainerConfiguration resourceConfiguration) - { - return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); - } + /// + protected override PapercutBuilder Clone( + IResourceConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); + } - /// - protected override PapercutBuilder Merge(PapercutConfiguration oldValue, PapercutConfiguration newValue) - { - return new PapercutBuilder(new PapercutConfiguration(oldValue, newValue)); + /// + protected override PapercutBuilder Clone(IContainerConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); + } + + /// + protected override PapercutBuilder Merge(PapercutConfiguration oldValue, PapercutConfiguration newValue) + { + return new PapercutBuilder(new PapercutConfiguration(oldValue, newValue)); + } } } \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutConfiguration.cs b/src/Testcontainers.Papercut/PapercutConfiguration.cs index b59f11465..45c8b0d9a 100644 --- a/src/Testcontainers.Papercut/PapercutConfiguration.cs +++ b/src/Testcontainers.Papercut/PapercutConfiguration.cs @@ -1,55 +1,56 @@ -namespace Testcontainers.Papercut; - -/// -[PublicAPI] -public sealed class PapercutConfiguration : ContainerConfiguration +namespace Testcontainers.Papercut { - /// - /// Initializes a new instance of the class. - /// - public PapercutConfiguration() + /// + [PublicAPI] + public sealed class PapercutConfiguration : ContainerConfiguration { - } + /// + /// Initializes a new instance of the class. + /// + public PapercutConfiguration() + { + } - /// - /// Initializes a new instance of the class. - /// - /// The Docker resource configuration. - public PapercutConfiguration(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 PapercutConfiguration(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 PapercutConfiguration(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 PapercutConfiguration(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 PapercutConfiguration(PapercutConfiguration resourceConfiguration) - : this(new PapercutConfiguration(), 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 PapercutConfiguration(PapercutConfiguration resourceConfiguration) + : this(new PapercutConfiguration(), 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 PapercutConfiguration(PapercutConfiguration oldValue, PapercutConfiguration newValue) - : base(oldValue, newValue) - { - // // Create an updated immutable copy of the module configuration. - // Config = BuildConfiguration.Combine(oldValue.Config, newValue.Config); + /// + /// Initializes a new instance of the class. + /// + /// The old Docker resource configuration. + /// The new Docker resource configuration. + public PapercutConfiguration(PapercutConfiguration oldValue, PapercutConfiguration newValue) + : base(oldValue, newValue) + { + // // Create an updated immutable copy of the module configuration. + // Config = BuildConfiguration.Combine(oldValue.Config, newValue.Config); + } } } \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutContainer.cs b/src/Testcontainers.Papercut/PapercutContainer.cs index b408240fb..1dd1c7757 100644 --- a/src/Testcontainers.Papercut/PapercutContainer.cs +++ b/src/Testcontainers.Papercut/PapercutContainer.cs @@ -1,76 +1,20 @@ -using System.Net.Http; -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace Testcontainers.Papercut; - -/// -[PublicAPI] -public sealed class PapercutContainer : DockerContainer +namespace Testcontainers.Papercut { - /// - /// Initializes a new instance of the class. - /// - /// The container configuration. - /// The logger. - public PapercutContainer(PapercutConfiguration configuration, ILogger logger) - : base(configuration, logger) - { - } - - public string WebUrl => "http://" + Hostname + ":" + GetMappedPublicPort(37408); - - public async Task GetMessages() - { - var client = new HttpClient(); - client.BaseAddress = new Uri(WebUrl); - var messageText = await client.GetStringAsync("/api/messages"); - return JsonConvert.DeserializeObject(messageText); + /// + [PublicAPI] + public sealed class PapercutContainer : DockerContainer + { + /// + /// Initializes a new instance of the class. + /// + /// The container configuration. + /// The logger. + public PapercutContainer(PapercutConfiguration configuration, ILogger logger) + : base(configuration, logger) + { + } + + public string WebUrl => "http://" + Hostname + ":" + GetMappedPublicPort(PapercutBuilder.WebInterfacePort); + public int PublicSmtpPort => GetMappedPublicPort(PapercutBuilder.SmtpPort); } - - public async Task GetMessage(string id) - { - var client = new HttpClient(); - client.BaseAddress = new Uri(WebUrl); - var messageText = await client.GetStringAsync($"/api/messages/{id}"); - return JsonConvert.DeserializeObject(messageText); - } - - public async Task DeleteMessages() - { - var client = new HttpClient(); - client.BaseAddress = new Uri(WebUrl); - var response = await client.DeleteAsync("/api/messages"); - return response.IsSuccessStatusCode; - } - - public async Task DeleteMessages(string id) - { - var client = new HttpClient(); - client.BaseAddress = new Uri(WebUrl); - var response = await client.DeleteAsync($"/api/messages/{id}"); - return response.IsSuccessStatusCode; - } - - public Task DownloadRaw(string id) - { - var client = new HttpClient(); - client.BaseAddress = new Uri(WebUrl); - return client.GetAsync($"/api/messages/{id}/raw"); - } - - public Task DownloadSection(string id, int index) - { - var client = new HttpClient(); - client.BaseAddress = new Uri(WebUrl); - return client.GetAsync($"/api/messages/{id}/sections/{index}"); - } - - public Task DownloadSectionContent(string id, string contentId) - { - var client = new HttpClient(); - client.BaseAddress = new Uri(WebUrl); - return client.GetAsync($"/api/messages/{id}/contents/{contentId}"); - } - } \ No newline at end of file diff --git a/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj b/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj index 4235a0201..4a2bad226 100644 --- a/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj +++ b/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj @@ -5,7 +5,8 @@ Liam Wilson, Andre Hofmeister and contributors A testcontainer that setups Papercut SMTP -Testcontainers for .NET is a library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions. + Testcontainers for .NET is a library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions. + Copyright (c) 2019 - 2023 Liam Wilson, Andre Hofmeister and other authors diff --git a/src/Testcontainers.Papercut/Usings.cs b/src/Testcontainers.Papercut/Usings.cs index 2cc17791b..2ee3367f6 100644 --- a/src/Testcontainers.Papercut/Usings.cs +++ b/src/Testcontainers.Papercut/Usings.cs @@ -1,8 +1,7 @@ -global using System; -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; -global using Microsoft.Extensions.Logging; \ No newline at end of file +global using Microsoft.Extensions.Logging; +global using System.Net; \ No newline at end of file diff --git a/src/Testcontainers.Papercut/EmailAddressDetail.cs b/tests/Testcontainers.Papercut.Tests/EmailAddressDetail.cs similarity index 100% rename from src/Testcontainers.Papercut/EmailAddressDetail.cs rename to tests/Testcontainers.Papercut.Tests/EmailAddressDetail.cs diff --git a/src/Testcontainers.Papercut/HeaderDetail.cs b/tests/Testcontainers.Papercut.Tests/HeaderDetail.cs similarity index 100% rename from src/Testcontainers.Papercut/HeaderDetail.cs rename to tests/Testcontainers.Papercut.Tests/HeaderDetail.cs diff --git a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs index 182951d76..1a54e88b4 100644 --- a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs +++ b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs @@ -1,7 +1,3 @@ -using System.Diagnostics; -using System.Linq; -using System.Net.Mail; - namespace Testcontainers.Papercut; public sealed class PapercutContainerTest : IAsyncLifetime @@ -23,22 +19,27 @@ public Task DisposeAsync() public async Task SendingAnEmail() { //Given - var client = new SmtpClient(_papercutContainer.Hostname,_papercutContainer.GetMappedPublicPort(25)); + var client = new SmtpClient(_papercutContainer.Hostname,_papercutContainer.PublicSmtpPort); //When client.Send("test@test.com","recipient@test.com","Test","A test message"); //Then - var result = await _papercutContainer.GetMessages(); + var httpClient = new HttpClient(); + httpClient.BaseAddress = new Uri(_papercutContainer.WebUrl); + var messageText = await httpClient.GetStringAsync("/api/messages"); + var result = JsonConvert.DeserializeObject(messageText); var startTimeout = Stopwatch.StartNew(); while (result.TotalMessageCount < 1 && startTimeout.Elapsed.TotalSeconds < 5) { - result = await _papercutContainer.GetMessages(); + messageText = await httpClient.GetStringAsync("/api/messages"); + result = JsonConvert.DeserializeObject(messageText); } Assert.Equal(1, result.TotalMessageCount); - var message = await _papercutContainer.GetMessage(result.Messages.Single().Id); + messageText = await httpClient.GetStringAsync($"/api/messages/{result.Messages.Single().Id}"); + var message = JsonConvert.DeserializeObject(messageText); Assert.Equal("Test",message.Subject); Assert.Equal("A test message\n",message.TextBody); Assert.Equal("test@test.com",message.From.Single().Address); diff --git a/src/Testcontainers.Papercut/PapercutMessage.cs b/tests/Testcontainers.Papercut.Tests/PapercutMessage.cs similarity index 91% rename from src/Testcontainers.Papercut/PapercutMessage.cs rename to tests/Testcontainers.Papercut.Tests/PapercutMessage.cs index ac831ff38..a6a32712d 100644 --- a/src/Testcontainers.Papercut/PapercutMessage.cs +++ b/tests/Testcontainers.Papercut.Tests/PapercutMessage.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using JetBrains.Annotations; + namespace Testcontainers.Papercut { public class PapercutMessage diff --git a/src/Testcontainers.Papercut/PapercutMessageCollection.cs b/tests/Testcontainers.Papercut.Tests/PapercutMessageCollection.cs similarity index 100% rename from src/Testcontainers.Papercut/PapercutMessageCollection.cs rename to tests/Testcontainers.Papercut.Tests/PapercutMessageCollection.cs diff --git a/src/Testcontainers.Papercut/PapercutMessageSummary.cs b/tests/Testcontainers.Papercut.Tests/PapercutMessageSummary.cs similarity index 100% rename from src/Testcontainers.Papercut/PapercutMessageSummary.cs rename to tests/Testcontainers.Papercut.Tests/PapercutMessageSummary.cs diff --git a/src/Testcontainers.Papercut/SectionDetail.cs b/tests/Testcontainers.Papercut.Tests/SectionDetail.cs similarity index 100% rename from src/Testcontainers.Papercut/SectionDetail.cs rename to tests/Testcontainers.Papercut.Tests/SectionDetail.cs diff --git a/tests/Testcontainers.Papercut.Tests/Usings.cs b/tests/Testcontainers.Papercut.Tests/Usings.cs index 346085388..c642cf202 100644 --- a/tests/Testcontainers.Papercut.Tests/Usings.cs +++ b/tests/Testcontainers.Papercut.Tests/Usings.cs @@ -1,3 +1,10 @@ -global using System.Threading.Tasks; global using DotNet.Testcontainers.Commons; -global using Xunit; \ No newline at end of file +global using Newtonsoft.Json; +global using System; +global using System.Collections.Generic; +global using System.Diagnostics; +global using System.Linq; +global using System.Net.Http; +global using System.Net.Mail; +global using System.Threading.Tasks; +global using Xunit; From b923b857819bbeaab6a568fe610c5703885a8842 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Tue, 14 Nov 2023 19:13:20 +0100 Subject: [PATCH 6/7] chore: Align Papercut implementation --- Testcontainers.sln | 28 ++-- src/Testcontainers.Consul/Usings.cs | 1 - .../PapercutBuilder.cs | 122 +++++++++--------- .../PapercutConfiguration.cs | 93 +++++++------ .../PapercutContainer.cs | 40 +++--- .../Testcontainers.Papercut.csproj | 7 +- src/Testcontainers.Papercut/Usings.cs | 4 +- .../EmailAddressDetail.cs | 8 -- .../HeaderDetail.cs | 8 -- .../PapercutContainerTest.cs | 74 +++++++---- .../PapercutMessage.cs | 20 --- .../PapercutMessageCollection.cs | 8 -- .../PapercutMessageSummary.cs | 10 -- .../SectionDetail.cs | 9 -- tests/Testcontainers.Papercut.Tests/Usings.cs | 9 +- 15 files changed, 199 insertions(+), 242 deletions(-) delete mode 100644 tests/Testcontainers.Papercut.Tests/EmailAddressDetail.cs delete mode 100644 tests/Testcontainers.Papercut.Tests/HeaderDetail.cs delete mode 100644 tests/Testcontainers.Papercut.Tests/PapercutMessage.cs delete mode 100644 tests/Testcontainers.Papercut.Tests/PapercutMessageCollection.cs delete mode 100644 tests/Testcontainers.Papercut.Tests/PapercutMessageSummary.cs delete mode 100644 tests/Testcontainers.Papercut.Tests/SectionDetail.cs diff --git a/Testcontainers.sln b/Testcontainers.sln index b4e64b120..176958bfa 100644 --- a/Testcontainers.sln +++ b/Testcontainers.sln @@ -63,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Neo4j", "src EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Oracle", "src\Testcontainers.Oracle\Testcontainers.Oracle.csproj", "{596EAFC1-0496-495C-B382-D57415FA456A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Papercut", "src\Testcontainers.Papercut\Testcontainers.Papercut.csproj", "{464F1120-A0DA-462B-B9E8-45176D883625}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.PostgreSql", "src\Testcontainers.PostgreSql\Testcontainers.PostgreSql.csproj", "{8AB91636-9055-4900-A72A-7CFFACDFDBF0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.PubSub", "src\Testcontainers.PubSub\Testcontainers.PubSub.csproj", "{E6642255-667D-476B-B584-089AA5E6C0B1}" @@ -135,6 +137,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Neo4j.Tests" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Oracle.Tests", "tests\Testcontainers.Oracle.Tests\Testcontainers.Oracle.Tests.csproj", "{4AC1088B-9965-4497-AC8E-570F1AD5631F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Papercut.Tests", "tests\Testcontainers.Papercut.Tests\Testcontainers.Papercut.Tests.csproj", "{904C8476-FCEF-41F0-8948-9EFA7C08712E}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Platform.Linux.Tests", "tests\Testcontainers.Platform.Linux.Tests\Testcontainers.Platform.Linux.Tests.csproj", "{DA1D7ADE-452C-4369-83CC-56289176EACD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Platform.Windows.Tests", "tests\Testcontainers.Platform.Windows.Tests\Testcontainers.Platform.Windows.Tests.csproj", "{3E55CBE8-AFE8-426D-9470-49D63CD1051C}" @@ -159,10 +163,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Tests", "tes EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.WebDriver.Tests", "tests\Testcontainers.WebDriver.Tests\Testcontainers.WebDriver.Tests.csproj", "{EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Papercut", "src\Testcontainers.Papercut\Testcontainers.Papercut.csproj", "{464F1120-A0DA-462B-B9E8-45176D883625}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcontainers.Papercut.Tests", "tests\Testcontainers.Papercut.Tests\Testcontainers.Papercut.Tests.csproj", "{904C8476-FCEF-41F0-8948-9EFA7C08712E}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -272,6 +272,10 @@ Global {596EAFC1-0496-495C-B382-D57415FA456A}.Debug|Any CPU.Build.0 = Debug|Any CPU {596EAFC1-0496-495C-B382-D57415FA456A}.Release|Any CPU.ActiveCfg = Release|Any CPU {596EAFC1-0496-495C-B382-D57415FA456A}.Release|Any CPU.Build.0 = Release|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Debug|Any CPU.Build.0 = Debug|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Release|Any CPU.ActiveCfg = Release|Any CPU + {464F1120-A0DA-462B-B9E8-45176D883625}.Release|Any CPU.Build.0 = Release|Any CPU {8AB91636-9055-4900-A72A-7CFFACDFDBF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8AB91636-9055-4900-A72A-7CFFACDFDBF0}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AB91636-9055-4900-A72A-7CFFACDFDBF0}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -416,6 +420,10 @@ Global {4AC1088B-9965-4497-AC8E-570F1AD5631F}.Debug|Any CPU.Build.0 = Debug|Any CPU {4AC1088B-9965-4497-AC8E-570F1AD5631F}.Release|Any CPU.ActiveCfg = Release|Any CPU {4AC1088B-9965-4497-AC8E-570F1AD5631F}.Release|Any CPU.Build.0 = Release|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Release|Any CPU.Build.0 = Release|Any CPU {DA1D7ADE-452C-4369-83CC-56289176EACD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DA1D7ADE-452C-4369-83CC-56289176EACD}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA1D7ADE-452C-4369-83CC-56289176EACD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -464,14 +472,6 @@ Global {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2}.Release|Any CPU.Build.0 = Release|Any CPU - {464F1120-A0DA-462B-B9E8-45176D883625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {464F1120-A0DA-462B-B9E8-45176D883625}.Debug|Any CPU.Build.0 = Debug|Any CPU - {464F1120-A0DA-462B-B9E8-45176D883625}.Release|Any CPU.ActiveCfg = Release|Any CPU - {464F1120-A0DA-462B-B9E8-45176D883625}.Release|Any CPU.Build.0 = Release|Any CPU - {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {904C8476-FCEF-41F0-8948-9EFA7C08712E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {3F2E254F-C203-43FD-A078-DC3E2CBC0F9F} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} @@ -499,6 +499,7 @@ Global {BF37BEA1-0816-4326-B1E0-E82290F8FCE0} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {ADC2372B-6FE0-421D-8277-BB628E8EFC22} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {596EAFC1-0496-495C-B382-D57415FA456A} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} + {464F1120-A0DA-462B-B9E8-45176D883625} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {8AB91636-9055-4900-A72A-7CFFACDFDBF0} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {E6642255-667D-476B-B584-089AA5E6C0B1} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} {A6D480BC-FDE8-4B92-A2A6-FF16BEE486AE} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} @@ -535,6 +536,7 @@ Global {87A3F137-6DC3-4CE5-91E6-01797D076086} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {D3F63405-C0FA-4F83-8B79-E30BFF5FF5BF} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {4AC1088B-9965-4497-AC8E-570F1AD5631F} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} + {904C8476-FCEF-41F0-8948-9EFA7C08712E} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {DA1D7ADE-452C-4369-83CC-56289176EACD} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {3E55CBE8-AFE8-426D-9470-49D63CD1051C} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {56D0DCA5-567F-4B3B-8B79-CB108F8EB8A6} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} @@ -547,7 +549,5 @@ Global {1A1983E6-5297-435F-B467-E8E1F11277D6} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {27CDB869-A150-4593-958F-6F26E5391E7C} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} {EBA72C3B-57D5-43FF-A5B4-3D55B3B6D4C2} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} - {464F1120-A0DA-462B-B9E8-45176D883625} = {673F23AE-7694-4BB9-ABD4-136D6C13634E} - {904C8476-FCEF-41F0-8948-9EFA7C08712E} = {7164F1FB-7F24-444A-ACD2-2C329C2B3CCF} EndGlobalSection EndGlobal diff --git a/src/Testcontainers.Consul/Usings.cs b/src/Testcontainers.Consul/Usings.cs index 49507dd3e..bf2829a65 100644 --- a/src/Testcontainers.Consul/Usings.cs +++ b/src/Testcontainers.Consul/Usings.cs @@ -1,5 +1,4 @@ global using System; -global using System.Net; global using Docker.DotNet.Models; global using DotNet.Testcontainers.Builders; global using DotNet.Testcontainers.Configurations; diff --git a/src/Testcontainers.Papercut/PapercutBuilder.cs b/src/Testcontainers.Papercut/PapercutBuilder.cs index 8c6636f8a..4a16972c2 100644 --- a/src/Testcontainers.Papercut/PapercutBuilder.cs +++ b/src/Testcontainers.Papercut/PapercutBuilder.cs @@ -1,75 +1,69 @@ -namespace Testcontainers.Papercut +namespace Testcontainers.Papercut; + +/// +[PublicAPI] +public sealed class PapercutBuilder : ContainerBuilder { - /// - [PublicAPI] - public sealed class PapercutBuilder : ContainerBuilder - { - private const string PapercutImage = "jijiechen/papercut:latest"; - internal const int SmtpPort = 25; - internal const int WebInterfacePort = 37408; + public const string PapercutImage = "jijiechen/papercut:latest"; - /// - /// Initializes a new instance of the class. - /// - public PapercutBuilder() - : this(new PapercutConfiguration()) - { - DockerResourceConfiguration = Init().DockerResourceConfiguration; - } + public const ushort HttpPort = 37408; - /// - /// Initializes a new instance of the class. - /// - /// The Docker resource configuration. - private PapercutBuilder(PapercutConfiguration resourceConfiguration) - : base(resourceConfiguration) - { - DockerResourceConfiguration = resourceConfiguration; - } + public const ushort SmtpPort = 25; - /// - protected override PapercutConfiguration DockerResourceConfiguration { get; } + /// + /// Initializes a new instance of the class. + /// + public PapercutBuilder() + : this(new PapercutConfiguration()) + { + DockerResourceConfiguration = Init().DockerResourceConfiguration; + } - /// - public override PapercutContainer Build() - { - Validate(); - return new PapercutContainer(DockerResourceConfiguration, TestcontainersSettings.Logger); - } + /// + /// Initializes a new instance of the class. + /// + /// The Docker resource configuration. + private PapercutBuilder(PapercutConfiguration resourceConfiguration) + : base(resourceConfiguration) + { + DockerResourceConfiguration = resourceConfiguration; + } - /// - protected override PapercutBuilder Init() - { - return base.Init() - .WithImage(PapercutImage) - .WithPortBinding(SmtpPort, true) - .WithPortBinding(WebInterfacePort, true) - .WithWaitStrategy( - Wait.ForUnixContainer() - .UntilHttpRequestIsSucceeded(strategy => - { - return strategy.ForPort(WebInterfacePort).ForStatusCode(HttpStatusCode.OK); - }) - ); - } + /// + protected override PapercutConfiguration DockerResourceConfiguration { get; } - /// - protected override PapercutBuilder Clone( - IResourceConfiguration resourceConfiguration) - { - return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); - } + /// + public override PapercutContainer Build() + { + Validate(); + return new PapercutContainer(DockerResourceConfiguration, TestcontainersSettings.Logger); + } - /// - protected override PapercutBuilder Clone(IContainerConfiguration resourceConfiguration) - { - return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); - } + /// + protected override PapercutBuilder Init() + { + return base.Init() + .WithImage(PapercutImage) + .WithPortBinding(HttpPort, true) + .WithPortBinding(SmtpPort, true) + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => request.ForPort(HttpPort))); + } + + /// + protected override PapercutBuilder Clone(IResourceConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); + } - /// - protected override PapercutBuilder Merge(PapercutConfiguration oldValue, PapercutConfiguration newValue) - { - return new PapercutBuilder(new PapercutConfiguration(oldValue, newValue)); - } + /// + protected override PapercutBuilder Clone(IContainerConfiguration resourceConfiguration) + { + return Merge(DockerResourceConfiguration, new PapercutConfiguration(resourceConfiguration)); + } + + /// + protected override PapercutBuilder Merge(PapercutConfiguration oldValue, PapercutConfiguration newValue) + { + return new PapercutBuilder(new PapercutConfiguration(oldValue, newValue)); } } \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutConfiguration.cs b/src/Testcontainers.Papercut/PapercutConfiguration.cs index 45c8b0d9a..6582a0276 100644 --- a/src/Testcontainers.Papercut/PapercutConfiguration.cs +++ b/src/Testcontainers.Papercut/PapercutConfiguration.cs @@ -1,56 +1,53 @@ -namespace Testcontainers.Papercut +namespace Testcontainers.Papercut; + +/// +[PublicAPI] +public sealed class PapercutConfiguration : ContainerConfiguration { - /// - [PublicAPI] - public sealed class PapercutConfiguration : ContainerConfiguration + /// + /// Initializes a new instance of the class. + /// + public PapercutConfiguration() { - /// - /// Initializes a new instance of the class. - /// - public PapercutConfiguration() - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// The Docker resource configuration. - public PapercutConfiguration(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 PapercutConfiguration(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 PapercutConfiguration(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 PapercutConfiguration(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 PapercutConfiguration(PapercutConfiguration resourceConfiguration) - : this(new PapercutConfiguration(), 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 PapercutConfiguration(PapercutConfiguration resourceConfiguration) + : this(new PapercutConfiguration(), 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 PapercutConfiguration(PapercutConfiguration oldValue, PapercutConfiguration newValue) - : base(oldValue, newValue) - { - // // Create an updated immutable copy of the module configuration. - // Config = BuildConfiguration.Combine(oldValue.Config, newValue.Config); - } + /// + /// Initializes a new instance of the class. + /// + /// The old Docker resource configuration. + /// The new Docker resource configuration. + public PapercutConfiguration(PapercutConfiguration oldValue, PapercutConfiguration newValue) + : base(oldValue, newValue) + { } } \ No newline at end of file diff --git a/src/Testcontainers.Papercut/PapercutContainer.cs b/src/Testcontainers.Papercut/PapercutContainer.cs index 1dd1c7757..e73e762e6 100644 --- a/src/Testcontainers.Papercut/PapercutContainer.cs +++ b/src/Testcontainers.Papercut/PapercutContainer.cs @@ -1,20 +1,30 @@ -namespace Testcontainers.Papercut +namespace Testcontainers.Papercut; + +/// +[PublicAPI] +public sealed class PapercutContainer : DockerContainer { - /// - [PublicAPI] - public sealed class PapercutContainer : DockerContainer + /// + /// Initializes a new instance of the class. + /// + /// The container configuration. + /// The logger. + public PapercutContainer(PapercutConfiguration configuration, ILogger logger) + : base(configuration, logger) { - /// - /// Initializes a new instance of the class. - /// - /// The container configuration. - /// The logger. - public PapercutContainer(PapercutConfiguration configuration, ILogger logger) - : base(configuration, logger) - { - } + } - public string WebUrl => "http://" + Hostname + ":" + GetMappedPublicPort(PapercutBuilder.WebInterfacePort); - public int PublicSmtpPort => GetMappedPublicPort(PapercutBuilder.SmtpPort); + /// + /// Gets the SMTP port. + /// + public ushort SmtpPort => GetMappedPublicPort(PapercutBuilder.SmtpPort); + + /// + /// Gets the Papercut base address. + /// + /// The Papercut base address. + public string GetBaseAddress() + { + return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(PapercutBuilder.HttpPort)).ToString(); } } \ No newline at end of file diff --git a/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj b/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj index 4a2bad226..054b86339 100644 --- a/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj +++ b/src/Testcontainers.Papercut/Testcontainers.Papercut.csproj @@ -2,12 +2,9 @@ netstandard2.0;netstandard2.1 latest - Liam Wilson, Andre Hofmeister and contributors - A testcontainer that setups Papercut SMTP - - Testcontainers for .NET is a library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions. - Copyright (c) 2019 - 2023 Liam Wilson, Andre Hofmeister and other authors + Liam Wilson, Andre Hofmeister and contributors + A Testcontainers Papercut module for testing SMTP clients and sending emails. diff --git a/src/Testcontainers.Papercut/Usings.cs b/src/Testcontainers.Papercut/Usings.cs index 2ee3367f6..bf2829a65 100644 --- a/src/Testcontainers.Papercut/Usings.cs +++ b/src/Testcontainers.Papercut/Usings.cs @@ -1,7 +1,7 @@ +global using System; 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 Microsoft.Extensions.Logging; -global using System.Net; \ No newline at end of file +global using Microsoft.Extensions.Logging; \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/EmailAddressDetail.cs b/tests/Testcontainers.Papercut.Tests/EmailAddressDetail.cs deleted file mode 100644 index 59cd50f9b..000000000 --- a/tests/Testcontainers.Papercut.Tests/EmailAddressDetail.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Testcontainers.Papercut -{ - public class EmailAddressDetail - { - public string Name { get; set; } - public string Address { get; set; } - } -} \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/HeaderDetail.cs b/tests/Testcontainers.Papercut.Tests/HeaderDetail.cs deleted file mode 100644 index 5a00d9632..000000000 --- a/tests/Testcontainers.Papercut.Tests/HeaderDetail.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Testcontainers.Papercut -{ - public class HeaderDetail - { - public string Name { get; set; } - public string Value { get; set; } - } -} \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs index 1a54e88b4..6c51f803c 100644 --- a/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs +++ b/tests/Testcontainers.Papercut.Tests/PapercutContainerTest.cs @@ -16,33 +16,57 @@ public Task DisposeAsync() [Fact] [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] - public async Task SendingAnEmail() + public async Task ReceivesSentMessage() { - //Given - var client = new SmtpClient(_papercutContainer.Hostname,_papercutContainer.PublicSmtpPort); - - //When - client.Send("test@test.com","recipient@test.com","Test","A test message"); - - //Then - var httpClient = new HttpClient(); - httpClient.BaseAddress = new Uri(_papercutContainer.WebUrl); - var messageText = await httpClient.GetStringAsync("/api/messages"); - var result = JsonConvert.DeserializeObject(messageText); - - var startTimeout = Stopwatch.StartNew(); - while (result.TotalMessageCount < 1 && startTimeout.Elapsed.TotalSeconds < 5) + // Given + const string subject = "Test"; + + Message[] messages; + + using var httpClient = new HttpClient(); + httpClient.BaseAddress = new Uri(_papercutContainer.GetBaseAddress()); + + using var smtpClient = new SmtpClient(_papercutContainer.Hostname, _papercutContainer.SmtpPort); + + // When + smtpClient.Send("from@example.com", "to@example.com", subject, "A test message"); + + do + { + var messagesJson = await httpClient.GetStringAsync("/api/messages") + .ConfigureAwait(false); + + var jsonDocument = JsonDocument.Parse(messagesJson); + messages = jsonDocument.RootElement.GetProperty("messages").Deserialize(); + } + while (messages.Length == 0); + + // Then + Assert.NotEmpty(messages); + Assert.Equal(subject, messages[0].Subject); + } + + private readonly struct Message + { + [JsonConstructor] + public Message(string id, string subject, string size, DateTime createdAt) { - messageText = await httpClient.GetStringAsync("/api/messages"); - result = JsonConvert.DeserializeObject(messageText); + Id = id; + Subject = subject; + Size = size; + CreatedAt = createdAt; } - - Assert.Equal(1, result.TotalMessageCount); - messageText = await httpClient.GetStringAsync($"/api/messages/{result.Messages.Single().Id}"); - var message = JsonConvert.DeserializeObject(messageText); - Assert.Equal("Test",message.Subject); - Assert.Equal("A test message\n",message.TextBody); - Assert.Equal("test@test.com",message.From.Single().Address); - Assert.Equal("recipient@test.com",message.To.Single().Address); + + [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.Papercut.Tests/PapercutMessage.cs b/tests/Testcontainers.Papercut.Tests/PapercutMessage.cs deleted file mode 100644 index a6a32712d..000000000 --- a/tests/Testcontainers.Papercut.Tests/PapercutMessage.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using JetBrains.Annotations; - -namespace Testcontainers.Papercut -{ - public class PapercutMessage - { - public string Id { get; set; } - public string Subject { get; set; } - public DateTime CreatedAt { get; set; } - public IEnumerable From { get; set; } - public IEnumerable To { get; set; } - public IEnumerable Cc { get; set; } - public IEnumerable BCc { get; set; } - [CanBeNull] public string HtmlBody { get; set; } - [CanBeNull] public string TextBody { get; set; } - public IEnumerable Headers { get; set; } - public IEnumerable Sections { get; set; } - } -} \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/PapercutMessageCollection.cs b/tests/Testcontainers.Papercut.Tests/PapercutMessageCollection.cs deleted file mode 100644 index 92aa75f7d..000000000 --- a/tests/Testcontainers.Papercut.Tests/PapercutMessageCollection.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Testcontainers.Papercut -{ - public class PapercutMessageCollection - { - public int TotalMessageCount { get; set; } - public IEnumerable Messages { get; set; } - } -} \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/PapercutMessageSummary.cs b/tests/Testcontainers.Papercut.Tests/PapercutMessageSummary.cs deleted file mode 100644 index 02bbbee08..000000000 --- a/tests/Testcontainers.Papercut.Tests/PapercutMessageSummary.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Testcontainers.Papercut -{ - public class PapercutMessageSummary - { - public string Id { get; set; } - public string Subject { get; set; } - public string Size { get; set; } - public DateTime CreatedAt { get; set; } - } -} \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/SectionDetail.cs b/tests/Testcontainers.Papercut.Tests/SectionDetail.cs deleted file mode 100644 index b569e8e43..000000000 --- a/tests/Testcontainers.Papercut.Tests/SectionDetail.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Testcontainers.Papercut -{ - public class SectionDetail - { - public string Id { get; set; } - public string MediaType { get; set; } - public string FileName { get; set; } - } -} \ No newline at end of file diff --git a/tests/Testcontainers.Papercut.Tests/Usings.cs b/tests/Testcontainers.Papercut.Tests/Usings.cs index c642cf202..1a5aa669f 100644 --- a/tests/Testcontainers.Papercut.Tests/Usings.cs +++ b/tests/Testcontainers.Papercut.Tests/Usings.cs @@ -1,10 +1,9 @@ -global using DotNet.Testcontainers.Commons; -global using Newtonsoft.Json; global using System; global using System.Collections.Generic; -global using System.Diagnostics; -global using System.Linq; global using System.Net.Http; global using System.Net.Mail; +global using System.Text.Json; +global using System.Text.Json.Serialization; global using System.Threading.Tasks; -global using Xunit; +global using DotNet.Testcontainers.Commons; +global using Xunit; \ No newline at end of file From 840198e42b264a89e9ff7cc641d788345d52562e Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Wed, 15 Nov 2023 18:52:28 +0100 Subject: [PATCH 7/7] chore: Remove using --- tests/Testcontainers.Papercut.Tests/Usings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Testcontainers.Papercut.Tests/Usings.cs b/tests/Testcontainers.Papercut.Tests/Usings.cs index 1a5aa669f..763582fff 100644 --- a/tests/Testcontainers.Papercut.Tests/Usings.cs +++ b/tests/Testcontainers.Papercut.Tests/Usings.cs @@ -1,5 +1,4 @@ global using System; -global using System.Collections.Generic; global using System.Net.Http; global using System.Net.Mail; global using System.Text.Json;