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); } }