public void GenericOnDemandRefreshCache_Defaults_Tests()
 {
     var timespan = TimeSpan.FromDays(1);
     using (var cache = new SpecificBackgroundRefreshCache<string, object>(timespan))
     {
         Assert.IsNull(cache.Get("non-existant"));
     }
 }
        public void RefreshAction_Populates_MissingCacheValues()
        {
            var timespan = TimeSpan.FromMilliseconds(50);
            var strategy = Expires.Always<int>();
            Func<string, int> factory = (key) => int.Parse(key);
            var cache = new SpecificBackgroundRefreshCache<string, int>(timespan, strategy, factory);

            cache.Add("1", 2);
            cache.Add("2", 3);
            Assert.AreEqual(2, cache.Get("1"));
            Assert.AreEqual(3, cache.Get("2"));

            System.Threading.Thread.Sleep(100);
            Assert.AreEqual(1, cache.Get("1"));
            Assert.AreEqual(2, cache.Get("2"));
            Assert.AreEqual(2, cache.Count);

            Assert.AreEqual(0, cache.Statistics.Cleanings.Value);
            Assert.AreEqual(0, cache.Statistics.Evictions.Value);
            Assert.AreEqual(4, cache.Statistics.Requests.Value);
            Assert.AreEqual(4, cache.Statistics.Hits.Value);
            Assert.AreEqual(4, cache.Statistics.Updates.Value);
            Assert.AreEqual(0, cache.Statistics.Misses.Value);
        }