public void EnumeratesWrappedItems() { var originalCollection = new ObservableCollection<ItemMetadata>() { new ItemMetadata(new object()), new ItemMetadata(new object()) }; IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => true); Assert.AreEqual(2, viewsCollection.Count()); Assert.AreSame(originalCollection[0].Item, viewsCollection.ElementAt(0)); Assert.AreSame(originalCollection[1].Item, viewsCollection.ElementAt(1)); }
public void ChangingSortComparisonCausesResortingOfCollection() { var originalCollection = new ObservableCollection<ItemMetadata>(); ViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true); var view1 = new MockSortableView1(); var view2 = new MockSortableView2(); var view3 = new MockSortableView3(); originalCollection.Add(new ItemMetadata(view2)); originalCollection.Add(new ItemMetadata(view3)); originalCollection.Add(new ItemMetadata(view1)); // ensure items are in original order Assert.AreSame(view2, viewsCollection.ElementAt(0)); Assert.AreSame(view3, viewsCollection.ElementAt(1)); Assert.AreSame(view1, viewsCollection.ElementAt(2)); // change sort comparison viewsCollection.SortComparison = Region.DefaultSortComparison; // ensure items are properly sorted Assert.AreSame(view1, viewsCollection.ElementAt(0)); Assert.AreSame(view2, viewsCollection.ElementAt(1)); Assert.AreSame(view3, viewsCollection.ElementAt(2)); }
public async Task ViewsCollectionSortedAfterAddingItemToOriginalCollection() { await ExecuteOnUIThread(() => { var originalCollection = new ObservableCollection<ItemMetadata>(); ViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true) { SortComparison = Region.DefaultSortComparison }; var view1 = new MockSortableView1(); var view2 = new MockSortableView2(); var view3 = new MockSortableView3(); originalCollection.Add(new ItemMetadata(view2)); originalCollection.Add(new ItemMetadata(view3)); originalCollection.Add(new ItemMetadata(view1)); Assert.AreSame(view1, viewsCollection.ElementAt(0)); Assert.AreSame(view2, viewsCollection.ElementAt(1)); Assert.AreSame(view3, viewsCollection.ElementAt(2)); }); }
public void ViewsCollectionSortedAfterAddingItemToOriginalCollection() { var originalCollection = new ObservableCollection<ItemMetadata>(); ViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true); viewsCollection.SortComparison = Region.DefaultSortComparison; var view1 = new MockSortableView1(); var view2 = new MockSortableView2(); var view3 = new MockSortableView3(); originalCollection.Add(new ItemMetadata(view2)); originalCollection.Add(new ItemMetadata(view3)); originalCollection.Add(new ItemMetadata(view1)); Assert.AreSame(view1, viewsCollection.ElementAt(0)); Assert.AreSame(view2, viewsCollection.ElementAt(1)); Assert.AreSame(view3, viewsCollection.ElementAt(2)); }
public async Task EnumeratesWrappedItems() { await ExecuteOnUIThread(() => { var originalCollection = new ObservableCollection<ItemMetadata>() { new ItemMetadata(new object()), new ItemMetadata(new object()) }; IViewsCollection viewsCollection = new ViewsCollection(originalCollection, x => true); Assert.AreEqual(2, viewsCollection.Count()); Assert.AreSame(originalCollection[0].Item, viewsCollection.ElementAt(0)); Assert.AreSame(originalCollection[1].Item, viewsCollection.ElementAt(1)); }); }