Exemplo n.º 1
0
            public void List_Clear_OnReadOnlyList_IsRejected()
            {
                var source = new List <int> {
                    13
                };
                var list = new ReadOnlyList <int>(source);

                list.Clear();
            }
Exemplo n.º 2
0
        public void TestClearException()
        {
            var list = new List <int> {
                7, 3, 5, 7, 20, 30
            };
            var readonlyList = new ReadOnlyList <int>(list);

            var exception = Assert.Throws <NotSupportedException>(() => readonlyList.Clear());

            Assert.Equal("Collection is read-only.", exception.Message);
        }