From cbd4d20eb802bc073a27a36f971cbbdabf641a5b Mon Sep 17 00:00:00 2001 From: Alexander Yumashev <33555768+alex-jitbit@users.noreply.github.com> Date: Sun, 3 Sep 2023 22:53:44 +0300 Subject: [PATCH] added eviction unittest --- UnitTests/UnitTests.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/UnitTests/UnitTests.cs b/UnitTests/UnitTests.cs index 78d11bd..8a9accf 100644 --- a/UnitTests/UnitTests.cs +++ b/UnitTests/UnitTests.cs @@ -18,6 +18,30 @@ public async Task TestGetSetCleanup() Assert.IsTrue(_cache.Count == 0); //cleanup job has run? } + [TestMethod] + public async Task TestEviction() + { + var list = new List>(); + for (int i = 0; i < 20; i++) + { + var cache = new FastCache(cleanupJobInterval: 200); + cache.AddOrUpdate(42, 42, TimeSpan.FromMilliseconds(100)); + list.Add(cache); + } + await Task.Delay(300); + + for (int i = 0; i < 20; i++) + { + Assert.IsTrue(list[i].Count == 0); //cleanup job has run? + } + + //cleanup + for (int i = 0; i < 20; i++) + { + list[i].Dispose(); + } + } + [TestMethod] public async Task Shortdelay() {