コード例 #1
0
        public void AssociativeCache_ShouldInitialize_SpecificCachePolicy()
        {
            AssociativeCache <string, string> cache = new AssociativeCache <string, string>(2, 10, new MRUPolicyFactory <string, string>());

            Assert.AreEqual(5, cache.GetCacheSets()[0].SetCapacity);
            Assert.IsTrue(cache.GetCacheSets().TrueForAll(s => s.CachePolicy.GetType() == typeof(MRUCachePolicy <string, string>)));
        }
コード例 #2
0
        public void AssociativeCache_CLear()
        {
            AssociativeCache <string, string> cache = new AssociativeCache <string, string>(3, 6);

            cache.Add("A", "dataA");
            cache.Add("B", "dataA");
            cache.Add("C", "dataA");
            cache.Add("D", "dataA");
            cache.Add("E", "dataA");

            cache.Clear();
            foreach (CacheSet <string, string> cacheSet in cache.GetCacheSets())
            {
                Assert.AreEqual(cacheSet.GetAllKeys().Count, 0);
            }
        }