diff --git a/src/Server/Database.cs b/src/Server/Database.cs index eda6044..5c73269 100644 --- a/src/Server/Database.cs +++ b/src/Server/Database.cs @@ -79,5 +79,9 @@ private void Clean() public void Dispose() { _cts.Cancel(); + _cts.Dispose(); + _data.Clear(); + _ex.Clear(); + GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/tests/Server.UnitTests/Database.cs b/tests/Server.UnitTests/Database.cs index bc599ac..88a315b 100644 --- a/tests/Server.UnitTests/Database.cs +++ b/tests/Server.UnitTests/Database.cs @@ -12,7 +12,7 @@ public class DatabaseTests [InlineData("", "")] public void SetGet(string key, string value) { - var db = new Database(); + using var db = new Database(); db.Set(key, value); var result = db.Get(key); Assert.Equal(value, result); @@ -23,7 +23,7 @@ public void SetGet(string key, string value) [InlineData("key2", "value", 10)] public void SetGetEx(string key, string value, long ex) { - var db = new Database(); + using var db = new Database(); db.Set(key, value, ex); var result = db.Get(key); Assert.Equal(value, result); @@ -37,7 +37,7 @@ public void SetGetEx(string key, string value, long ex) [Fact] public void AutoClean() { - var db = new Database(); + using var db = new Database(); db.Set("key1", "value"); db.Set("key2", "value", 50); db.Set("key3", "value", 20);