diff --git a/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs b/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs index 127194ebe..cefaf632d 100644 --- a/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs +++ b/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs @@ -1,23 +1,8 @@ namespace Testcontainers.Azurite; -public abstract class AzuriteContainerTest : IAsyncLifetime +public abstract class AzuriteContainerTest(AzuriteContainerTest.AzuriteFixture fixture) { - private readonly AzuriteContainer _azuriteContainer; - - private AzuriteContainerTest(AzuriteContainer azuriteContainer) - { - _azuriteContainer = azuriteContainer; - } - - public Task InitializeAsync() - { - return _azuriteContainer.StartAsync(); - } - - public Task DisposeAsync() - { - return _azuriteContainer.DisposeAsync().AsTask(); - } + private readonly AzuriteContainer _azuriteContainer = fixture.Container; [Fact] [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] @@ -72,48 +57,45 @@ private static bool HasError(NullableResponse } } + public class AzuriteFixture(IMessageSink messageSink) : ContainerFixture(messageSink); + [UsedImplicitly] - public sealed class AzuriteDefaultConfiguration : AzuriteContainerTest + public sealed class AzuriteInMemoryFixture(IMessageSink messageSink) : AzuriteFixture(messageSink) { - public AzuriteDefaultConfiguration() - : base(new AzuriteBuilder().Build()) - { - } + protected override AzuriteBuilder Configure(AzuriteBuilder builder) => builder.WithInMemoryPersistence(); } [UsedImplicitly] - public sealed class AzuriteInMemoryConfiguration : AzuriteContainerTest + public sealed class AzuriteMemoryLimitFixture(IMessageSink messageSink) : AzuriteFixture(messageSink) { - public AzuriteInMemoryConfiguration() - : base(new AzuriteBuilder().WithInMemoryPersistence().Build()) - { - } + public const int MemoryLimitInMb = 64; + + protected override AzuriteBuilder Configure(AzuriteBuilder builder) => builder.WithInMemoryPersistence(MemoryLimitInMb); } [UsedImplicitly] - public sealed class AzuriteMemoryLimitConfiguration : AzuriteContainerTest - { - private const int MemoryLimitInMb = 64; + public sealed class AzuriteDefaultConfiguration(AzuriteFixture fixture) : AzuriteContainerTest(fixture), IClassFixture; - private static readonly string[] LineEndings = { "\r\n", "\n" }; + [UsedImplicitly] + public sealed class AzuriteInMemoryConfiguration(AzuriteInMemoryFixture fixture) : AzuriteContainerTest(fixture), IClassFixture; - public AzuriteMemoryLimitConfiguration() - : base(new AzuriteBuilder().WithInMemoryPersistence(MemoryLimitInMb).Build()) - { - } + [UsedImplicitly] + public sealed class AzuriteMemoryLimitConfiguration(AzuriteMemoryLimitFixture fixture) : AzuriteContainerTest(fixture), IClassFixture + { + private static readonly string[] LineEndings = { "\r\n", "\n" }; [Fact] public async Task MemoryLimitIsConfigured() { // Given - var (stdout, _) = await _azuriteContainer.GetLogsAsync(timestampsEnabled: false) + var (stdout, _) = await fixture.Container.GetLogsAsync(timestampsEnabled: false) .ConfigureAwait(true); // When var firstLine = stdout.Split(LineEndings, StringSplitOptions.RemoveEmptyEntries).First(); // Then - Assert.StartsWith(string.Format(CultureInfo.InvariantCulture, "In-memory extent storage is enabled with a limit of {0:F2} MB", MemoryLimitInMb), firstLine); + Assert.StartsWith(string.Format(CultureInfo.InvariantCulture, "In-memory extent storage is enabled with a limit of {0:F2} MB", AzuriteMemoryLimitFixture.MemoryLimitInMb), firstLine); } } } \ No newline at end of file diff --git a/tests/Testcontainers.Azurite.Tests/Testcontainers.Azurite.Tests.csproj b/tests/Testcontainers.Azurite.Tests/Testcontainers.Azurite.Tests.csproj index 3c88aadf8..98813cb20 100644 --- a/tests/Testcontainers.Azurite.Tests/Testcontainers.Azurite.Tests.csproj +++ b/tests/Testcontainers.Azurite.Tests/Testcontainers.Azurite.Tests.csproj @@ -15,6 +15,7 @@ + \ No newline at end of file diff --git a/tests/Testcontainers.Azurite.Tests/Usings.cs b/tests/Testcontainers.Azurite.Tests/Usings.cs index 645e958bd..270a35c11 100644 --- a/tests/Testcontainers.Azurite.Tests/Usings.cs +++ b/tests/Testcontainers.Azurite.Tests/Usings.cs @@ -8,4 +8,6 @@ global using Azure.Storage.Queues; global using DotNet.Testcontainers.Commons; global using JetBrains.Annotations; -global using Xunit; \ No newline at end of file +global using Testcontainers.Xunit; +global using Xunit; +global using Xunit.Abstractions; \ No newline at end of file