public void TestContainsValue() { HashDictionary dict = new HashDictionary(); Assert.AreEqual(0, dict.Count); Assert.IsFalse(dict.ContainsValue("B")); Assert.IsFalse(dict.ContainsValue(null)); dict.Add("A", "A"); dict.Add("B", "B"); dict.Add("C", "C"); Assert.AreEqual(3, dict.Count); Assert.IsTrue(dict.ContainsValue("B")); Assert.IsFalse(dict.ContainsValue(null)); dict.Add(null, null); Assert.AreEqual(4, dict.Count); Assert.IsTrue(dict.ContainsValue("B")); Assert.IsTrue(dict.ContainsValue(null)); dict.Remove("B"); Assert.AreEqual(3, dict.Count); Assert.IsFalse(dict.ContainsValue("B")); Assert.IsTrue(dict.ContainsValue(null)); dict.Remove(null); Assert.AreEqual(2, dict.Count); Assert.IsFalse(dict.ContainsValue("B")); Assert.IsFalse(dict.ContainsValue(null)); dict.Clear(); Assert.AreEqual(0, dict.Count); Assert.IsFalse(dict.ContainsValue("A")); Assert.IsFalse(dict.ContainsValue(null)); }
public void TestSafeHashSet() { SafeHashSet set = new SafeHashSet(); Assert.AreEqual(0, set.Count); Assert.IsFalse(set.Contains("B")); Assert.IsFalse(set.Contains(null)); set.Add("A"); set.Add("B"); set.Add("C"); Assert.AreEqual(3, set.Count); Assert.IsTrue(set.Contains("B")); Assert.IsFalse(set.Contains(null)); set.Add(null); Assert.AreEqual(4, set.Count); Assert.IsTrue(set.Contains("B")); Assert.IsTrue(set.Contains(null)); set.Remove("B"); Assert.AreEqual(3, set.Count); Assert.IsFalse(set.Contains("B")); Assert.IsTrue(set.Contains(null)); set.Remove(null); Assert.AreEqual(2, set.Count); Assert.IsFalse(set.Contains("B")); Assert.IsFalse(set.Contains(null)); set.Clear(); Assert.AreEqual(0, set.Count); Assert.IsFalse(set.Contains("A")); Assert.IsFalse(set.Contains(null)); HashDictionary dict = new HashDictionary(); dict.Add("A", "A"); dict.Add("B", "B"); dict.Add("C", "C"); dict.Add("Null", null); ICollection col = dict.Values; set = new SafeHashSet(col); Assert.AreEqual(4, set.Count); Assert.IsTrue(set.Contains("A")); Assert.IsTrue(set.Contains(null)); }