Exemplo n.º 1
0
        public void IsReadonlyAddException()
        {
            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.Add(13, "f"));
        }
Exemplo n.º 2
0
        public void ReadOnlyAddPairException()
        {
            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();
            KeyValuePair <int, string> pair = new KeyValuePair <int, string>(13, "f");

            Assert.Throws <NotSupportedException>(() => dictionary.Add(pair));
        }