From bdcabde4b1345ba9c098fc8750536aa73baea8b8 Mon Sep 17 00:00:00 2001 From: Hamed Ansarian Date: Sat, 7 Feb 2026 13:53:58 +0100 Subject: [PATCH 1/2] Refactor Redis container initialization and disposal in integration tests --- .../DistributedNonceIntegrationTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs b/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs index 0e97641..ec3fb47 100644 --- a/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs +++ b/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs @@ -20,7 +20,7 @@ public class DistributedNonceIntegrationTests private IContainer? _redisContainer; private const string RedisImage = "redis:latest"; private const int RedisPort = 6379; - private IConnectionMultiplexer? _mux; + private ConnectionMultiplexer? _mux; private ServiceProvider? _provider; private IClient _clientReturns5 = default!; private IClient _clientReturns7 = default!; @@ -28,8 +28,7 @@ public class DistributedNonceIntegrationTests [OneTimeSetUp] public async Task OneTimeSetUp() { - _redisContainer = new ContainerBuilder() - .WithImage(RedisImage) + _redisContainer = new ContainerBuilder(RedisImage) .WithCleanUp(true) .WithName($"dtm-redis-{Guid.NewGuid():N}") .WithPortBinding(RedisPort, true) @@ -76,7 +75,8 @@ public async Task OneTimeTearDown() scope?.Dispose(); if (_provider is not null) await _provider.DisposeAsync(); - _mux?.Dispose(); + if (_mux is not null) + await _mux.DisposeAsync(); } [Test, Order(1)] From 889225bc513627209e629721e34104df92af52b9 Mon Sep 17 00:00:00 2001 From: Hamed Ansarian Date: Sat, 7 Feb 2026 13:58:27 +0100 Subject: [PATCH 2/2] Remove redundant Redis connection disposal in integration tests teardown --- .../DistributedNonce.Tests/DistributedNonceIntegrationTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs b/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs index ec3fb47..0065574 100644 --- a/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs +++ b/tests/DistributedNonce.Tests/DistributedNonceIntegrationTests.cs @@ -75,8 +75,6 @@ public async Task OneTimeTearDown() scope?.Dispose(); if (_provider is not null) await _provider.DisposeAsync(); - if (_mux is not null) - await _mux.DisposeAsync(); } [Test, Order(1)]