public void ContainsKey1() { DoubleKeyMultiDictionary <string, string, int> dictionary = new DoubleKeyMultiDictionary <string, string, int>(); dictionary.Add("k1", "k2", 10); dictionary.Add("k3", "k2", 20); Assert.IsTrue(dictionary.ContainsKey1("k1")); Assert.IsTrue(dictionary.ContainsKey1("k3")); Assert.IsFalse(dictionary.ContainsKey1("bla")); }
public void RemoveForKey1() { DoubleKeyMultiDictionary <string, string, int> dictionary = new DoubleKeyMultiDictionary <string, string, int>(); dictionary.Add("k1", "k2", 10); dictionary.Add("k1", "k2", 10); // the same keys and the value dictionary.Add("k3", "k2", 20); Assert.IsTrue(dictionary.RemoveForKey1("k1")); Assert.AreEqual(1, dictionary.Count); Assert.AreEqual(20, dictionary.GetValues("k3", "k2").First()); Assert.IsFalse(dictionary.ContainsKey1("k1")); dictionary = new DoubleKeyMultiDictionary <string, string, int>(); dictionary.Add("k1", "k2", 10); dictionary.Add("k1", "k2", 10); // the same keys and the value dictionary.Add("k3", "k2", 20); int counter = 0; bool result = dictionary.RemoveForKey1("k1", (k1, k2, v) => { ++counter; return(counter < 2); } ); Assert.IsTrue(result); Assert.AreEqual(2, dictionary.Count); Assert.AreEqual(10, dictionary.GetValues("k1", "k2").First()); Assert.AreEqual(20, dictionary.GetValues("k3", "k2").First()); Assert.IsTrue(dictionary.ContainsKey1("k1")); Assert.IsFalse(dictionary.RemoveForKey1("bla1")); }