Skip to content

Commit

Permalink
tests: refactor tests RegisterPostEvictionCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
alastairtree committed Sep 19, 2020
1 parent e66522f commit 21b1436
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions LazyCache.UnitTests/CachingServiceMemoryCacheProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ public void GetOrAddWithImmediateExpirationAndCallbackInTheDelegateDoesExpireIte
[Test]
public async Task GetOrAddAsyncWithImmediateExpirationAndCallbackInTheDelegateDoesExpireItemsAndFireTheCallback()
{
var millisecondsCacheDuration = 100;
var millisecondsCacheDuration = 1000;
var callbackHasFired = false;
var validResult = await sut.GetOrAddAsync(
TestKey,
Expand All @@ -845,7 +845,7 @@ public async Task GetOrAddAsyncWithImmediateExpirationAndCallbackInTheDelegateDo
.WithImmediateAbsoluteExpiration(TimeSpan.FromMilliseconds(millisecondsCacheDuration))
.RegisterPostEvictionCallback((key, value, reason, state) => callbackHasFired = true));
// trigger expiry
Thread.Sleep(TimeSpan.FromMilliseconds(millisecondsCacheDuration + 50));
Thread.Sleep(TimeSpan.FromMilliseconds(millisecondsCacheDuration + 1000));

Assert.That(validResult, Is.Not.Null);
Assert.That(callbackHasFired, Is.True);
Expand Down

0 comments on commit 21b1436

Please sign in to comment.