public void statistics_are_updated_with_hits()
 {
     var cache = new DictionaryBasedCache(100, 1024 * 9);
     cache.PutRecord(1, new PrepareLogRecord(1, Guid.NewGuid(), _id, 1, 0, "test", 1, DateTime.UtcNow, 
                                             PrepareFlags.None, "type", new byte[0], new byte[1024]));
     PrepareLogRecord read;
     cache.TryGetRecord(1, out read);
     Assert.AreEqual(1, cache.GetStatistics().HitCount);
 }
 public void empty_cache_has_zeroed_statistics()
 {
     var cache = new DictionaryBasedCache(100, 1024 * 9);
     var stats = cache.GetStatistics();
     Assert.AreEqual(0, stats.MissCount);
     Assert.AreEqual(0, stats.HitCount);
     Assert.AreEqual(0, stats.Size);
     Assert.AreEqual(0, stats.Count);
 }
Exemplo n.º 3
0
        public void empty_cache_has_zeroed_statistics()
        {
            var cache = new DictionaryBasedCache(100, 1024 * 9);
            var stats = cache.GetStatistics();

            Assert.AreEqual(0, stats.MissCount);
            Assert.AreEqual(0, stats.HitCount);
            Assert.AreEqual(0, stats.Size);
            Assert.AreEqual(0, stats.Count);
        }
Exemplo n.º 4
0
        public void statistics_are_updated_with_misses()
        {
            var cache = new DictionaryBasedCache(100, 1024 * 9);

            cache.PutRecord(1, new PrepareLogRecord(1, Guid.NewGuid(), _id, 1, 0, "test", 1, DateTime.UtcNow,
                                                    PrepareFlags.None, "type", new byte[0], new byte[1024]));
            PrepareLogRecord read;

            cache.TryGetRecord(0, out read);
            Assert.AreEqual(1, cache.GetStatistics().MissCount);
        }
Exemplo n.º 5
0
        public void statistics_are_updated_with_total_size()
        {
            var cache  = new DictionaryBasedCache(100, 1024 * 9);
            var record = new PrepareLogRecord(1, Guid.NewGuid(), _id, 1, 0, "test", 1, DateTime.UtcNow,
                                              PrepareFlags.None, "type", new byte[0], new byte[1024]);

            cache.PutRecord(1, record);
            PrepareLogRecord read;

            cache.TryGetRecord(0, out read);
            Assert.AreEqual(record.InMemorySize, cache.GetStatistics().Size);
        }
 public void statistics_are_updated_with_total_size()
 {
     var cache = new DictionaryBasedCache(100, 1024 * 9);
     var record = new PrepareLogRecord(1, Guid.NewGuid(), _id, 1, 0, "test", 1, DateTime.UtcNow,
                                       PrepareFlags.None, "type", new byte[0], new byte[1024]);
     cache.PutRecord(1, record);
     PrepareLogRecord read;
     cache.TryGetRecord(0, out read);
     Assert.AreEqual(record.InMemorySize, cache.GetStatistics().Size);
 }