public void Initializes() { var source = new ObservableCollection <Model <int> > { Model.Create(1), Model.Create(2), }; using (var indexed = source.AsMappingView( Vm.Create, (x, i) => x.WithIndex(i))) { using (var indexedUpdating = source.AsMappingView( Vm.Create, (x, i) => x.WithIndex(i))) { using (var indexedNewing = source.AsMappingView( Vm.Create, (x, i) => Vm.Create(x.Model, i))) { var views = new[] { indexed, indexedUpdating, indexedNewing, }; foreach (var view in views) { CollectionAssert.AreEqual(source, view.Select(x => x.Model)); CollectionAssert.AreEqual(source.Select((_, i) => i), view.Select(x => x.Index)); } } } } }
public void NewsOnRemoveTwoItems(int removeAt) { var source = new ObservableCollection <Model <int> > { Model.Create(1), Model.Create(2) }; using (var view = source.AsMappingView( Vm.Create, (x, i) => Vm.Create(x.Model, i))) { source.RemoveAt(removeAt); Assert.AreEqual(1, view.Count); Assert.AreSame(source[0], view[0].Model); Assert.AreEqual(0, view[0].Index); } }