public void ContainsKeyTest()
        {
            GenericCache <int, int> cache = new GenericCache <int, int>();

            cache.Add(1, 1001);
            cache.Add(2, 1002);
            Assert.IsTrue(cache.ContainsKey(1));
            Assert.IsFalse(cache.ContainsKey(3));
        }
Exemplo n.º 2
0
        public void GenericCacheTest()
        {
            var cacheHelper = new GenericCache <string, string>();

            cacheHelper.Add("hello", "world");

            Assert.AreEqual <int>(1, cacheHelper.Count);
            Assert.AreEqual <bool>(true, cacheHelper.ContainsKey("hello"));
            Assert.AreEqual <bool>(false, cacheHelper.ContainsKey("hi"));

            var val = "";

            cacheHelper.TryGetValue("hello", out val);
            Assert.AreEqual <string>("world", val);

            cacheHelper.Clear();
            Assert.AreEqual <int>(0, cacheHelper.Count);
        }