Exemplo n.º 1
0
        public void NearCacheListenNoneCacheStatisticsTest()
        {
            LocalNamedCache localcache = new LocalNamedCache();
            INamedCache     safecache  = CacheFactory.GetCache(CacheName);
            NearCache       nearcache  = new NearCache(localcache, safecache, CompositeCacheStrategyType.ListenNone);

            nearcache.Clear();

            Hashtable ht = new Hashtable();

            ht.Add(1, "Aleks");
            ht.Add(2, "Ana");
            ht.Add(3, "Goran");
            ht.Add(4, "Ivan");
            nearcache.InsertAll(ht);
            foreach (DictionaryEntry entry in ht)
            {
                Assert.IsTrue(nearcache.Contains(entry.Key));
            }
            Assert.AreEqual(ht.Count, nearcache.CacheHits);

            localcache.LocalCache = new LocalCache(Int32.MaxValue, 1);
            Thread.Sleep(1);
            foreach (DictionaryEntry entry in ht)
            {
                Assert.IsTrue(nearcache.Contains(entry.Key));
            }
            Assert.AreEqual(ht.Count, nearcache.CacheMisses);

            nearcache.Clear();
            nearcache.Destroy();
            Assert.IsFalse(nearcache.IsActive);
        }