Skip to content

Commit

Permalink
Fix flaky tests that were sensitive to sub-millisecond latency variat…
Browse files Browse the repository at this point in the history
…ions in Environment.TickCount64
  • Loading branch information
neon-sunset committed Oct 6, 2022
1 parent 3d961ca commit dc24be0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task Cached_TryGet_ReturnsValueBeforeExpiration_DoesNotReturnAfter(
Assert.True(foundBefore);
Assert.Equal(value, cachedBefore.Value);

await Task.Delay(delayTolerance);
await Task.Delay(delayTolerance + 1);
var foundAfter = Cached<string>.TryGet(key, out _);

Assert.False(foundAfter);
Expand Down
2 changes: 1 addition & 1 deletion tests/FastCache.CachedTests/Cached_Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task Cached_Update_PreservesExpiration(int milliseconds)
await Task.Delay(milliseconds - delayTolerance);
var updated = Cached<string>.TryGet(key, out var cached) && cached.Update(valueAfter);

await Task.Delay(delayTolerance);
await Task.Delay(delayTolerance + 1);
var foundAfter = Cached<string>.TryGet(key, out _);

Assert.True(updated);
Expand Down

0 comments on commit dc24be0

Please sign in to comment.