コード例 #1
0
        public static void GetItemTests_Negative()
        {
            string[] anArray = new string[] { "one", "two", "three", "four", "five" };
            ReadOnlyObservableCollection <string> readOnlyCol =
                new ReadOnlyObservableCollection <string>(new ObservableCollection <string>(anArray));
            IReadOnlyList_T_Test <string> helper = new IReadOnlyList_T_Test <string>(readOnlyCol, anArray);

            helper.Item_get_Tests_Negative();
        }
コード例 #2
0
        public static void Ctor_Tests()
        {
            string[] anArray = new string[] { "one", "two", "three", "four", "five" };
            ReadOnlyObservableCollection <string> readOnlyCol =
                new ReadOnlyObservableCollection <string>(new ObservableCollection <string>(anArray));
            IReadOnlyList_T_Test <string> helper = new IReadOnlyList_T_Test <string>(readOnlyCol, anArray);

            helper.InitialItems_Tests();
            IList <string> readOnlyColAsIList = readOnlyCol;

            Assert.True(readOnlyColAsIList.IsReadOnly, "ReadOnlyObservableCollection should be readOnly.");
        }
コード例 #3
0
        public static void CannotModifyDictionaryTests_Negative()
        {
            string[] anArray = new string[] { "one", "two", "three", "four", "five" };
            ReadOnlyObservableCollection <string> readOnlyCol =
                new ReadOnlyObservableCollection <string>(new ObservableCollection <string>(anArray));
            IReadOnlyList_T_Test <string> helper = new IReadOnlyList_T_Test <string>();
            IList <string> readOnlyColAsIList    = readOnlyCol;

            Assert.Throws <NotSupportedException>(() => readOnlyColAsIList.Add("seven"));
            Assert.Throws <NotSupportedException>(() => readOnlyColAsIList.Insert(0, "nine"));
            Assert.Throws <NotSupportedException>(() => readOnlyColAsIList.Remove("one"));
            Assert.Throws <NotSupportedException>(() => readOnlyColAsIList.RemoveAt(0));
            Assert.Throws <NotSupportedException>(() => readOnlyColAsIList.Clear());
            helper.VerifyReadOnlyCollection(readOnlyCol, anArray);
        }