Skip to content

Commit

Permalink
added eviction unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-jitbit committed Sep 3, 2023
1 parent b43b000 commit cbd4d20
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions UnitTests/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FastCache<int, int>>();
for (int i = 0; i < 20; i++)
{
var cache = new FastCache<int, int>(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()
{
Expand Down

0 comments on commit cbd4d20

Please sign in to comment.