public void ValueCollection() { ReadWriteTestMultiDictionary <string, int> dict = CreateTestReadWriteDictionary(); ICollection <int> valueColl = dict["Eric"]; Assert.AreEqual(3, valueColl.Count); valueColl.Add(19); valueColl.Add(-4); Assert.IsTrue(valueColl.Remove(1)); Assert.IsTrue(valueColl.Remove(19)); valueColl.Add(12); string[] s_array = new string[] { "Eric", "Clapton", "Rules", "The", "World" }; int[][] i_array = new int[][] { new int[] { 9, 11, -4, 12 }, new int[] { 6, 10 }, new int[] { 4 }, new int[] { 1, 2, 3, 4, 5, 6 }, new int[] { 8 } }; CheckOrderedMultiDictionaryContents(dict, s_array, i_array, "foo", 113, null, null); dict.Remove("Eric", 12); dict.Add("Eric", 19); InterfaceTests.TestReadWriteCollectionGeneric(valueColl, new int[] { 9, 11, -4, 19 }, true); dict.Remove("Eric"); InterfaceTests.TestReadWriteCollectionGeneric(valueColl, new int[] { }, true); InterfaceTests.TestReadWriteCollectionGeneric(dict["BananaZip"], new int[] { }, true); dict["The"].Clear(); Assert.IsFalse(dict.ContainsKey("The")); valueColl = dict["Foo"]; valueColl.Add(3); valueColl.Add(4); valueColl.Add(5); s_array = new string[] { "Clapton", "Rules", "World", "Foo" }; i_array = new int[][] { new int[] { 6, 10 }, new int[] { 4 }, new int[] { 8 }, new int[] { 3, 4, 5 } }; CheckOrderedMultiDictionaryContents(dict, s_array, i_array, "fizzle", 113, null, null); ICollection <int> valueColl2 = dict["Foo"]; Assert.IsFalse(object.ReferenceEquals(valueColl, valueColl2)); valueColl2.Add(11); valueColl.Add(19); Assert.IsTrue(Algorithms.EqualCollections(valueColl, valueColl2)); }
public void Remove2() { ReadWriteTestMultiDictionary <string, int> dict = CreateTestReadWriteDictionary(); Assert.IsTrue(dict.Remove(new KeyValuePair <string, ICollection <int> >("Eric", new int[] { 9, 1, 11 }))); Assert.IsFalse(dict.Remove(new KeyValuePair <string, ICollection <int> >("Rules", new int[] { }))); Assert.IsTrue(dict.Remove(new KeyValuePair <string, ICollection <int> >("The", new int[] { 4, 2, 11 }))); Assert.IsFalse(dict.Remove(new KeyValuePair <string, ICollection <int> >("Clapton", new int[] { 0, 1 }))); Assert.IsFalse(dict.Remove(new KeyValuePair <string, ICollection <int> >("foo", new int[] { 0, 1 }))); string[] s_array = new string[] { "Clapton", "Rules", "The", "World" }; int[][] i_array = new int[][] { new int[] { 6, 10 }, new int[] { 4 }, new int[] { 1, 3, 5, 6 }, new int[] { 8 } }; CheckOrderedMultiDictionaryContents(dict, s_array, i_array, "foo", 113, null, null); }
public void Remove1() { ReadWriteTestMultiDictionary <string, int> dict = CreateTestReadWriteDictionary(); Assert.IsTrue(dict.Remove("Eric")); Assert.IsTrue(dict.Remove("Rules")); Assert.IsFalse(dict.Remove("Eric")); Assert.IsFalse(dict.Remove("foo")); Assert.IsTrue(dict.Remove("World", 8)); Assert.IsTrue(dict.Remove("The", 2)); Assert.IsTrue(dict.Remove("The", 6)); Assert.IsFalse(dict.Remove("The", 6)); Assert.IsFalse(dict.Remove("The", 11)); string[] s_array = new string[] { "Clapton", "The" }; int[][] i_array = new int[][] { new int[] { 6, 10 }, new int[] { 1, 3, 4, 5 } }; CheckOrderedMultiDictionaryContents(dict, s_array, i_array, "foo", 113, null, null); }