diff --git a/tests/Foundatio.Tests/Caching/InMemoryCacheClientTests.cs b/tests/Foundatio.Tests/Caching/InMemoryCacheClientTests.cs index 13a18d28..b88b3976 100644 --- a/tests/Foundatio.Tests/Caching/InMemoryCacheClientTests.cs +++ b/tests/Foundatio.Tests/Caching/InMemoryCacheClientTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; using Foundatio.Caching; @@ -194,7 +194,9 @@ public async Task SetAllShouldExpire() var expiry = TimeSpan.FromMilliseconds(50); await client.SetAllAsync(new Dictionary { { "test", "value" } }, expiry); - await Task.Delay(expiry); + + // Add 1ms to the expiry to ensure the cache has expired as the delay window is not guaranteed to be exact. + await Task.Delay(expiry.Add(TimeSpan.FromMilliseconds(1))); Assert.False(await client.ExistsAsync("test")); }