Beispiel #1
0
        public void TryGetValue()
        {
            var dic = new qckdev.Collections.CacheDictionary <int, string>()
            {
                CacheTimeout = TimeSpan.FromMilliseconds(200)
            };

            dic.Add(1, "a");
            dic.Add(2, "b");
            dic.Add(3, "c");

            dic.TryGetValue(1, out string value);
            Assert.AreEqual("a", value);
        }
Beispiel #2
0
        public void TryGetValue_WithDelay()
        {
            var dic = new qckdev.Collections.CacheDictionary <int, string>()
            {
                CacheTimeout = TimeSpan.FromMilliseconds(200)
            };

            dic.Add(1, "a");
            System.Threading.Thread.Sleep(210);
            dic.Add(2, "b");
            dic.Add(3, "c");

            dic.TryGetValue(1, out string value);
            Assert.AreEqual(null, value);
        }