Skip to content

Commit 35c9904

Browse files
committed
Add Sleep(1000) in SlidingCacheTests
1 parent a235842 commit 35c9904

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/System.Linq.Dynamic.Core.Tests/Util/Cache/SlidingCacheTests.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq.Dynamic.Core.Util;
33
using System.Linq.Dynamic.Core.Util.Cache;
44
using System.Linq.Expressions;
5+
using System.Threading;
56
using FluentAssertions;
67
using Xunit;
78

@@ -114,7 +115,7 @@ public void SlidingCache_TestAutoExpire()
114115

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

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

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

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

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

173174
// Ensure one item is in the cache
174175
cache.Count.Should().Be(1, $"Expected 1 items in the cache, had {cache.Count}");
175176
}
177+
178+
private static void Sleep()
179+
{
180+
Thread.Sleep(1000);
181+
}
176182
}

0 commit comments

Comments
 (0)