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() {