Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }
Example #4
0
        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));
        }
Example #5
0
        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);
        }