Skip to content

Commit

Permalink
Add Sleep(1000) in SlidingCacheTests
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Feb 14, 2024
1 parent a235842 commit 35c9904
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq.Dynamic.Core.Util;
using System.Linq.Dynamic.Core.Util.Cache;
using System.Linq.Expressions;
using System.Threading;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -114,7 +115,7 @@ public void SlidingCache_TestAutoExpire()

// Since the cache cleanup is triggered by a Task and not on the same thread,
// give it a moment for the cleanup to happen
Threading.Thread.Sleep(10);
Sleep();

// Ensure one item is in the cache
cache.Count.Should().Be(0, $"Expected 0 items in the cache, had {cache.Count}");
Expand Down Expand Up @@ -158,7 +159,7 @@ public void SlidingCache_TestMinNumberBeforeTests()

// Since the cache cleanup is triggered by a Task and not on the same thread,
// give it a moment for the cleanup to happen
Threading.Thread.Sleep(10);
Sleep();

// Ensure one item is in the cache
cache.Count.Should().Be(1, $"Expected 1 items in the cache, only had {cache.Count}");
Expand All @@ -168,9 +169,14 @@ public void SlidingCache_TestMinNumberBeforeTests()

// Since the cache cleanup is triggered by a Task and not on the same thread,
// give it a moment for the cleanup to happen
Threading.Thread.Sleep(10);
Sleep();

// Ensure one item is in the cache
cache.Count.Should().Be(1, $"Expected 1 items in the cache, had {cache.Count}");
}

private static void Sleep()
{
Thread.Sleep(1000);
}
}

0 comments on commit 35c9904

Please sign in to comment.