Пример #1
0
        public void NullKeyContainsKeyException()
        {
            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.ContainsKey(null));
        }
Пример #2
0
        public void ContainsKeyTest()
        {
            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.True(dictionary.ContainsKey(7));
        }
Пример #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));
        }
Пример #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));
        }