public void UpdatesAccordingly() { List <int> list = new List <int>(); var collection = new ObservableGroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length); collection.ReplaceWith(list); var scheduler = new TestScheduler(); var observer = scheduler.CreateObserver <int>(); collection.TotalCount.Subscribe(observer); collection.InsertItem(20); collection.InsertItem(2); collection.RemoveItemAt(0, 0); collection.RemoveItemAt(0, 0); observer.Messages.AssertEqual( OnNext(0, 0), OnNext(0, 1), OnNext(0, 2), OnNext(0, 1), OnNext(0, 0) ); }
public void SendsEventWhenFirstItemOfSectionAdded() { List <int> list = new List <int> { 8, 3, 1, 2 }; var collection = new ObservableGroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length); collection.ReplaceWith(list); var scheduler = new TestScheduler(); var observer = scheduler.CreateObserver <CollectionChange>(); collection.CollectionChanges.SelectMany(l => l.ToObservable()).Subscribe(observer); collection.InsertItem(20); var change = new CollectionChange { Index = new SectionedIndex(1, 0), Type = CollectionChangeType.AddSection }; observer.Messages.AssertEqual( OnNext(0, change) ); }
public void SendsEventWhenItemAdded() { List <int> list = new List <int> { 40, 70, 8, 3, 1, 2 }; var collection = new ObservableGroupedOrderedCollection <int>(i => i, i => i, i => i.ToString().Length); collection.ReplaceWith(list); var scheduler = new TestScheduler(); var observer = scheduler.CreateObserver <ICollectionChange>(); collection.CollectionChange.Subscribe(observer); collection.InsertItem(20); ICollectionChange change = new AddRowCollectionChange <int>(new SectionedIndex(1, 0), 20); observer.Messages.AssertEqual( OnNext(0, change) ); }