예제 #1
0
        public void AddingToOriginalCollectionFiresAddCollectionChangeEvent()
        {
            var originalCollection           = new ObservableCollection <ItemMetadata>();
            IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);

            var eventTracker = new CollectionChangedTracker(viewsCollection);

            originalCollection.Add(new ItemMetadata(new ContentView()));

            Assert.Contains(NotifyCollectionChangedAction.Add, eventTracker.ActionsFired);
        }
예제 #2
0
        public void AddingToOriginalCollectionFiresResetNotificationIfSortComparisonSet()
        {
            // Reset is fired to support the need to resort after updating the collection
            var originalCollection = new ObservableCollection <ItemMetadata>();
            var viewsCollection    = new ViewsCollection(originalCollection, (i) => true);

            viewsCollection.SortComparison = (a, b) => { return(0); };

            var eventTracker = new CollectionChangedTracker(viewsCollection);

            originalCollection.Add(new ItemMetadata(new ContentView()));

            Assert.Contains(NotifyCollectionChangedAction.Add, eventTracker.ActionsFired);
            Assert.Equal(
                1,
                eventTracker.ActionsFired.Count(a => a == NotifyCollectionChangedAction.Reset));
        }