From f8fd16edb2926fa33e4d7800619ac67e6df0de97 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Mon, 20 Oct 2025 12:49:04 +0300 Subject: [PATCH] fix issue --- ChatBot.Tests/Data/MigrationsTests.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ChatBot.Tests/Data/MigrationsTests.cs b/ChatBot.Tests/Data/MigrationsTests.cs index ad04ddb..d566f3d 100644 --- a/ChatBot.Tests/Data/MigrationsTests.cs +++ b/ChatBot.Tests/Data/MigrationsTests.cs @@ -10,6 +10,7 @@ public class MigrationsTests : IDisposable { private readonly ServiceProvider _serviceProvider; private readonly ChatBotDbContext _dbContext; + private bool _disposed; public MigrationsTests() { @@ -324,10 +325,25 @@ public class MigrationsTests : IDisposable remainingMessageCount.Should().Be(0); } + protected virtual void Dispose(bool disposing) + { + if (_disposed) + { + return; + } + + if (disposing) + { + _dbContext?.Dispose(); + _serviceProvider?.Dispose(); + } + + _disposed = true; + } + public void Dispose() { - _dbContext?.Dispose(); - _serviceProvider?.Dispose(); + Dispose(true); GC.SuppressFinalize(this); } }