Пример #1
0
        public void Add()
        {
            var dic = new qckdev.Collections.CacheDictionary <int, string>();

            dic.Add(1, "a");
            dic.Add(2, "b");
            dic.Add(3, "c");
            Assert.AreEqual(3, dic.Count);
        }
Пример #2
0
        public void Count()
        {
            var dic = new qckdev.Collections.CacheDictionary <int, string>()
            {
                CacheTimeout = TimeSpan.FromMilliseconds(200)
            };

            dic.Add(1, "a");
            dic.Add(2, "b");
            dic.Add(3, "c");
            Assert.AreEqual(3, dic.Count);
        }
Пример #3
0
        public void Count_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");
            Assert.AreEqual(2, dic.Count);
        }
Пример #4
0
        public void ContainsKey()
        {
            var dic = new qckdev.Collections.CacheDictionary <int, string>()
            {
                CacheTimeout = TimeSpan.FromMilliseconds(200)
            };

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

            Assert.IsTrue(dic.ContainsKey(1));
        }
Пример #5
0
        public void ContainsKey_WithDelay(int key, bool expected)
        {
            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");

            Assert.AreEqual(expected, dic.ContainsKey(key));
        }
Пример #6
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);
        }
Пример #7
0
        public void Add_TooManyItems()
        {
            const int count = 1000;
            var       dic   = new qckdev.Collections.CacheDictionary <int, string>()
            {
                CacheTimeout = TimeSpan.FromMilliseconds(200)
            };

            for (int i = 0; i < count; i++)
            {
                dic.Add(i, $"Item {i}");
            }
            Assert.AreEqual(count, dic.Count);
        }