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 129e798 commit e66522f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions LazyCache.UnitTests/CachingServiceMemoryCacheProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,10 @@ public void GetOrAddWithCancellationExpiryBasedOnTimerAndCallbackInTheDelegateDo
TestKey,
entry =>
{
entry.RegisterPostEvictionCallback((key, value, reason, state) => callbackHasFired = true);
return new ComplexTestObject();
}, new MemoryCacheEntryOptions()
.AddExpirationToken(expireToken));
.AddExpirationToken(expireToken)
.RegisterPostEvictionCallback((key, value, reason, state) => callbackHasFired = true));
// trigger expiry
Thread.Sleep(TimeSpan.FromMilliseconds(millisecondsCacheDuration + 50));

Expand All @@ -820,9 +820,10 @@ public void GetOrAddWithImmediateExpirationAndCallbackInTheDelegateDoesExpireIte
TestKey,
entry =>
{
entry.RegisterPostEvictionCallback((key, value, reason, state) => callbackHasFired = true);
return new ComplexTestObject();
}, LazyCacheEntryOptions.WithImmediateAbsoluteExpiration(TimeSpan.FromMilliseconds(millisecondsCacheDuration)));
}, LazyCacheEntryOptions
.WithImmediateAbsoluteExpiration(TimeSpan.FromMilliseconds(millisecondsCacheDuration))
.RegisterPostEvictionCallback((key, value, reason, state) => callbackHasFired = true));
// trigger expiry
Thread.Sleep(TimeSpan.FromMilliseconds(millisecondsCacheDuration + 50));

Expand All @@ -839,9 +840,10 @@ public async Task GetOrAddAsyncWithImmediateExpirationAndCallbackInTheDelegateDo
TestKey,
entry =>
{
entry.RegisterPostEvictionCallback((key, value, reason, state) => callbackHasFired = true);
return Task.FromResult(new ComplexTestObject());
}, LazyCacheEntryOptions.WithImmediateAbsoluteExpiration(TimeSpan.FromMilliseconds(millisecondsCacheDuration)));
}, LazyCacheEntryOptions
.WithImmediateAbsoluteExpiration(TimeSpan.FromMilliseconds(millisecondsCacheDuration))
.RegisterPostEvictionCallback((key, value, reason, state) => callbackHasFired = true));
// trigger expiry
Thread.Sleep(TimeSpan.FromMilliseconds(millisecondsCacheDuration + 50));

Expand Down

0 comments on commit e66522f

Please sign in to comment.