예제 #1
0
        public void CacheObjectGetValueByIndex()
        {
            ICache cacheObject = new CachedMemory(1, @".\cache-test.txt");

            Assert.IsTrue(File.Exists(@".\cache-test.txt"));
            Assert.AreEqual(cacheObject.GetCacheSize(), 0);

            cacheObject.Add("unittest", "item");
            Assert.AreEqual(cacheObject.GetCacheSize(), 1);
            Assert.AreEqual(cacheObject.Get("unittest"), "item");

            cacheObject.Add("unittest", "12345");
            Assert.AreEqual(cacheObject.GetCacheSize(), 1);
            Assert.AreEqual(cacheObject.Get("unittest"), "12345");
        }
예제 #2
0
        public void CacheObjectAddItemToCachePastCapacitySize()
        {
            ICache cacheObject = new CachedMemory(1, @".\cache-test.txt");

            Assert.IsTrue(File.Exists(@".\cache-test.txt"));
            Assert.AreEqual(cacheObject.GetCacheSize(), 0);

            cacheObject.Add("unittest-1", "item");
            Assert.AreEqual(cacheObject.GetCacheSize(), 1);
            Assert.AreEqual(cacheObject.Get("unittest-1"), "item");

            cacheObject.Add("unittest-2", "item");
            Assert.AreEqual(cacheObject.GetCacheSize(), 1);
            Assert.AreEqual(cacheObject.Get("unittest-2"), "item");
        }