public async Task AddOrInsertCachedItemAsync() { ObjectCache cache = MemoryCache.Default; var policy = new CacheItemPolicy() { SlidingExpiration = TimeSpan.FromMinutes(1) }; var value = await cache.AddOrGetExistingAsync <int>("foo", async() => { await Task.Delay(100); return(1); }, policy); Assert.AreEqual(1, value); }