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 CreateInstance_WithValues() { var dic = new qckdev.Collections.CacheDictionary <int, string> { { 1, "a" }, { 2, "b" }, { 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 Values() { var dic = new qckdev.Collections.CacheDictionary <int, string>() { CacheTimeout = TimeSpan.FromMilliseconds(200) }; dic[1] = "a"; dic[2] = "b"; dic[3] = "c"; Assert.AreEqual(3, dic.Values.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 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); }
public void Values_WithDelay() { var dic = new qckdev.Collections.CacheDictionary <int, string>() { CacheTimeout = TimeSpan.FromMilliseconds(200) }; dic[1] = "a"; System.Threading.Thread.Sleep(210); dic[2] = "b"; dic[3] = "c"; Assert.AreEqual(2, dic.Values.Count); }
public void This_Set_Existing() { var dic = new qckdev.Collections.CacheDictionary <int, string>() { CacheTimeout = TimeSpan.FromMilliseconds(200) }; dic[1] = "a"; dic[2] = "b"; dic[3] = "c"; dic[1] = "x"; Assert.AreEqual("x", dic[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 This_Set_Existing_WithDelay() { var dic = new qckdev.Collections.CacheDictionary <int, string>() { CacheTimeout = TimeSpan.FromMilliseconds(200) }; dic[1] = "a"; System.Threading.Thread.Sleep(210); dic[2] = "b"; dic[3] = "c"; dic[1] = "x"; Assert.AreEqual("x", dic[1]); }