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(); }
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."); }
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); }