Exemplo n.º 1
0
        public void GetCacheItem_Miss()
        {
            // when
            _cache.GetCacheItem <object>("key1");

            // then
            var ratio = _cache.Statistics.SafeGetValue <decimal?>(CacheStatisticsKeys.CacheHitRatio);

            Assert.That(ratio, Is.EqualTo(0m));
        }
Exemplo n.º 2
0
        public void GetCacheItemShouldRecordTime()
        {
            //when
            DateTimeOffset expectedTime = DateTimeOffset.Now;

            _cache.GetCacheItem <object>("key1");

            //then
            Thread.Sleep(60);
            AssertAccessTime(_cache.Statistics, CacheStatisticsKeys.LastUse, expectedTime);
        }
Exemplo n.º 3
0
        public void GetCacheItemShouldNotRecordTime()
        {
            //when
            _cache.GetCacheItem <object>("key1");

            //then
            AssertNoAccessTime(_cache.Statistics, CacheStatisticsKeys.LastWrite);
        }
        public void GetCacheItemShouldRecordReadTime()
        {
            // given
            _cache.AddOrUpdate("key1", new object());
            Thread.Sleep(60);

            // when
            _cache.GetCacheItem <object>("key1");
            DateTimeOffset expectedTime = DateTimeOffset.Now;

            // then
            CacheItemAccessInfo itemStats =
                _cache.Statistics.SafeGetValue <IDictionary <string, CacheItemAccessInfo> >(CacheStatisticsKeys.ItemAccess)
                ["key1"];

            AssertAccessTime(itemStats.LastRead, expectedTime);
        }