Skip to content

Commit a8e5a18

Browse files
committed
Tighten test
1 parent ee3c52f commit a8e5a18

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Polly.Caching.MemoryCache.SharedSpecs/MemoryCacheProviderSpecs.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,23 @@ public void Put_should_put_item_using_passed_nonsliding_ttl()
131131
Ttl ttl = new Ttl(shimTimeSpan, false);
132132
provider.Put(key, value, ttl);
133133

134-
Thread.Sleep(shimTimeSpan + shimTimeSpan);
135-
134+
// Initially (before ttl expires), should be able to get value from cache.
136135
#if PORTABLE
137136
object got;
138137
memoryCache.TryGetValue(key, out got);
139138
#else
140139
object got = memoryCache[key];
141140
#endif
141+
got.Should().BeSameAs(value);
142+
143+
// Wait until the TTL on the cache item should have expired.
144+
Thread.Sleep(shimTimeSpan + shimTimeSpan);
145+
146+
#if PORTABLE
147+
memoryCache.TryGetValue(key, out got);
148+
#else
149+
got = memoryCache[key];
150+
#endif
142151

143152
got.Should().NotBeSameAs(value);
144153
got.Should().BeNull();

0 commit comments

Comments
 (0)