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); }
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); }
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); }
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)); }
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)); }
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); }
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); }