public void TestContainsKey() { IMultiMap <int, int> map = HashMultiMap <int, int> .Create(); map.Add(3, 2); Assert.IsTrue(map.ContainsKey(3)); Assert.IsFalse(map.ContainsKey(45)); }
public void TestAddAll() { IMultiMap <int, int> map = HashMultiMap <int, int> .Create(); map.Add(2, 5); map.Add(2, 4); map.Add(2, 3); map.Add(1, 5); map.Add(1, 6); IMultiMap <int, int> map2 = HashMultiMap <int, int> .Create(); map.Add(7, 5); map.Add(7, 4); map.Add(7, 3); map.Add(8, 5); map.Add(8, 6); map.AddAll(map2); foreach (int key in map2.Keys) { Assert.IsTrue(map.ContainsKey(key)); foreach (int value in map2.Get(key)) { Assert.IsTrue(map.ContainsValue(value)); } } }
public virtual void TestContains() { Assert.IsTrue(mm.Put("key1", "value1")); Assert.IsTrue(mm.Put("key1", "value2")); Assert.IsTrue(mm.Put("key1", "value3")); Assert.IsTrue(mm.Put("key2", "value4")); Assert.IsTrue(mm.Put("key2", "value5")); Assert.IsFalse(mm.ContainsKey("key3")); Assert.IsTrue(mm.ContainsKey("key1")); Assert.IsFalse(mm.ContainsValue("value6")); Assert.IsTrue(mm.ContainsValue("value4")); Assert.IsFalse(mm.ContainsEntry("key1", "value4")); Assert.IsFalse(mm.ContainsEntry("key2", "value3")); Assert.IsTrue(mm.ContainsEntry("key1", "value1")); Assert.IsTrue(mm.ContainsEntry("key2", "value5")); }
public void TestRemoveAll() { IMultiMap <int, int> map = HashMultiMap <int, int> .Create(); map.Add(2, 3); map.Add(2, 4); map.Add(2, 5); map.RemoveAll(2); Assert.IsFalse(map.ContainsKey(2)); Assert.IsFalse(map.ContainsValue(4)); Assert.IsFalse(map.ContainsValue(5)); Assert.IsFalse(map.ContainsValue(3)); }
public bool ContainsKey(TKey key) { return(map.ContainsKey(key)); }
/// <inheritdoc /> public bool ContainsKey(string key) { return(contents.ContainsKey(key)); }