Exemple #1
0
        public void FlushShouldRecordTime()
        {
            //when
            DateTimeOffset expectedTime = DateTimeOffset.Now;

            _cache.Flush();

            //then
            Thread.Sleep(60);
            AssertAccessTime(_cache.Statistics, CacheStatisticsKeys.LastUse, expectedTime);
        }
Exemple #2
0
        public void FlushShouldResetToNoRecordedTime()
        {
            //given
            _cache.AddOrUpdate("key1", "whatever");

            //when
            _cache.Flush();

            //then
            AssertNoAccessTime(_cache.Statistics, CacheStatisticsKeys.LastWrite);
        }
Exemple #3
0
        public void FlushShouldResetToZero()
        {
            // given
            _cache.AddOrUpdate("key1", new object());
            _cache.GetOrAdd("key1", _ => new object());

            // when
            _cache.Flush();

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

            Assert.That(ratio, Is.Null);
        }
        public void FlushShouldRemoveAllItemStats()
        {
            // given
            _cache.AddOrUpdate("key1", new object());
            _cache.AddOrUpdate("key2", new object());
            Assert.IsNotEmpty(
                _cache.Statistics.SafeGetValue <IDictionary <string, CacheItemAccessInfo> >(CacheStatisticsKeys.ItemAccess),
                "checking assumptions");

            // when
            _cache.Flush();

            // then
            var stats =
                _cache.Statistics.SafeGetValue <IDictionary <string, CacheItemAccessInfo> >(CacheStatisticsKeys.ItemAccess);

            Assert.That(stats, Is.Empty);
        }