public void NullKeyRemoveException() { var dictionary = new DictionaryCollection <int?, string>(5); dictionary.Add(1, "a"); dictionary.Add(2, "b"); dictionary.Add(10, "c"); dictionary.Add(7, "d"); dictionary.Add(12, "e"); Assert.Throws <ArgumentNullException>(() => dictionary.Remove(null)); }
public void ReadOnlyRemoveException() { var dictionary = new DictionaryCollection <int, string>(5); dictionary.Add(1, "a"); dictionary.Add(2, "b"); dictionary.Add(10, "c"); dictionary.Add(7, "d"); dictionary.Add(12, "e"); dictionary = dictionary.ReadOnlyDictionary(); Assert.Throws <NotSupportedException>(() => dictionary.Remove(2)); }
public void RemoveTest() { var dictionary = new DictionaryCollection <int, string>(5); dictionary.Add(1, "a"); dictionary.Add(2, "b"); dictionary.Add(10, "c"); dictionary.Add(7, "d"); dictionary.Add(12, "e"); dictionary.Remove(2); Assert.False(dictionary.ContainsKey(2)); }
public void RemoveLastPairTest() { var dictionary = new DictionaryCollection <int, string>(5); dictionary.Add(1, "a"); dictionary.Add(2, "b"); dictionary.Add(10, "c"); dictionary.Add(7, "d"); dictionary.Add(12, "e"); KeyValuePair <int, string> pair = new KeyValuePair <int, string>(12, "e"); dictionary.Remove(pair); Assert.False(dictionary.ContainsKey(12)); }
public void RemoveThenAddOnEmptySpaceTest() { var dictionary = new DictionaryCollection <int, string>(5); dictionary.Add(1, "a"); dictionary.Add(2, "b"); dictionary.Add(10, "c"); dictionary.Add(7, "d"); dictionary.Add(12, "e"); KeyValuePair <int, string> pair = new KeyValuePair <int, string>(2, "b"); dictionary.Remove(pair); dictionary.Add(5, "b"); Assert.Contains(5, dictionary); }