public void DeleteItemsTest() { var observableCollection = new ObservableCollection <int>(new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); var rool = new ReadOnlyObservableList <int>(observableCollection); var frooc = new FilteredReadOnlyObservableList <int>(rool, i => i % 2 == 0); Assert.AreEqual(frooc.Count, 5); observableCollection.Remove(3); observableCollection.RemoveAt(1); observableCollection.Remove(9); int item = 4; var iterator = frooc.GetEnumerator(); while (iterator.MoveNext()) { Assert.AreEqual(iterator.Current, item); item += 2; } Assert.AreEqual(item, 12); Assert.AreEqual(frooc.Count, 4); }
public void MoveItemsTest() { var observableCollection = new ObservableCollection <int>(new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); var rool = new ReadOnlyObservableList <int>(observableCollection); var frooc = new FilteredReadOnlyObservableList <int>(rool, i => i % 2 == 0); Assert.AreEqual(frooc.Count, 5); //[2 4 6 8 10] observableCollection.Move(1, 7); //[4 6 8 2 10] observableCollection.Move(3, 5); //[4 6 8 2 10] observableCollection.Move(3, 2); //[6 4 8 2 10] int[] a = new[] { 6, 4, 8, 2, 10 }; var iterator = frooc.GetEnumerator(); int j = 0; while (iterator.MoveNext()) { Assert.AreEqual(iterator.Current, a[j]); j++; } Assert.AreEqual(frooc.Count, 5); }
public void OperationsTest() { var observableCollection = new ObservableCollection <int>(new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }); var rool = new ReadOnlyObservableList <int>(observableCollection); var frooc = new FilteredReadOnlyObservableList <int>(rool, i => i % 2 == 0); Assert.AreEqual(frooc.Count, 10); //[2 4 6 8 10 12 14 16 18 20] observableCollection.Remove(4); //[2 6 8 10 12 14 16 18 20] observableCollection.Move(6, 13); //[2 6 10 12 14 8 16 18 20] observableCollection.Add(22); //[2 6 10 12 14 8 16 18 20 22] observableCollection.Insert(3, 4); //[2 4 6 10 12 14 8 16 18 20 22] observableCollection.RemoveAt(20); //[2 4 6 10 12 14 8 16 18 20] observableCollection[0] = 24; //[24 2 4 6 10 12 14 8 16 18 20] int[] a = new[] { 24, 2, 4, 6, 10, 12, 14, 8, 16, 18, 20 }; var iterator = frooc.GetEnumerator(); int j = 0; while (iterator.MoveNext()) { Assert.AreEqual(iterator.Current, a[j]); j++; } Assert.AreEqual(frooc.Count, a.Length); }