Beispiel #1
0
        public void ReadonlyDictionaryCantChange()
        {
            var underTest = new ReadonlyDictionary <string, string>(new Dictionary <string, string> {
                { "a", "a" }
            });

            Assert.Throws <NotSupportedException>(() => underTest.Remove("b"));
            Assert.Throws <NotSupportedException>(() => underTest.Remove(new KeyValuePair <string, string>("b", "b")));
            Assert.Throws <NotSupportedException>(() => underTest.Add("b", "b"));
            Assert.Throws <NotSupportedException>(() => underTest.Add(new KeyValuePair <string, string>("b", "b")));
            Assert.Throws <NotSupportedException>(() => underTest.Clear());
            Assert.Throws <NotSupportedException>(() => underTest["a"] = "a");
        }