public async Task Remove() { var list = new SortedSetReactiveCollectionSource <int>(); var notificationsTask = list.ReactiveCollection.Changes .Take(3) .ToArray() .ToTask(); list.Add(1); list.Remove(1); await Verify(notificationsTask); }
public async Task Remove() { var list = new SortedSetReactiveCollectionSource <int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); list.Add(1); list.Remove(1); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Remove); notification.NewItems.Should().BeEmpty(); notification.OldItems.Should().Equal(1); notification.Current.Should().BeEmpty(); notification.Index.Should().Be(0); }
public async Task Remove() { var list = new SortedSetReactiveCollectionSource<int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); list.Add(1); list.Remove(1); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Remove); notification.NewItems.Should().BeEmpty(); notification.OldItems.Should().Equal(1); notification.Current.Should().BeEmpty(); notification.Index.Should().Be(0); }
public async Task Remove_from_filtered_set() { var list = new SortedSetReactiveCollectionSource<int>(); var projectedList = list .ReactiveCollection .Where(x => x % 2 == 0); var notificationTask = projectedList.Changes .Skip(2) .FirstAsync() .ToTask(); list.Add(1); list.Add(2); list.Add(3); list.Remove(2); var notification = await notificationTask; notification.Index.Should().Be(0); notification.Action.Should().Be(NotifyCollectionChangedAction.Remove); notification.OldItems.Should().Equal(2); notification.NewItems.Should().BeEmpty(); notification.Current.Should().BeEmpty(); }
public async Task Remove_from_projected_set() { var list = new SortedSetReactiveCollectionSource<int>(); var projectedList = list.ReactiveCollection .Select(x => x.ToString(CultureInfo.InvariantCulture)); var notificationTask = projectedList.Changes .Skip(4) .FirstAsync() .ToTask(); list.Add(1); list.Add(2); list.Add(3); list.Remove(2); var notification = await notificationTask; notification.Index.Should().Be(1); notification.Action.Should().Be(NotifyCollectionChangedAction.Remove); notification.NewItems.Should().BeEmpty(); notification.OldItems.Should().Equal("2"); notification.Current.Should().Equal("1", "3"); }
public void SortedSet_ToObservableCollection_Remove_multiple() { var list = new SortedSetReactiveCollectionSource<int>(); var observableCollection = list.ReactiveCollection.ToObservableCollection(); using (Observable .FromEventPattern<NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>(eh => ((INotifyCollectionChanged)observableCollection).CollectionChanged += eh, eh => ((INotifyCollectionChanged)observableCollection).CollectionChanged -= eh) .Subscribe()) { list.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7 }); list.Remove(3); list.Remove(4); list.Remove(5); observableCollection.Should().Equal(1, 2, 6, 7); } }
public async Task SortedSet_ToObservableCollection_Remove() { var list = new SortedSetReactiveCollectionSource<int>(); var observableCollection = (INotifyCollectionChanged)list.ReactiveCollection.ToObservableCollection(); var eventsTask = Observable .FromEventPattern<NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>(eh => observableCollection.CollectionChanged += eh, eh => observableCollection.CollectionChanged -= eh) .Take(3) .Select(x => x.EventArgs) .ToArray() .ToTask(); list.Add(1); list.Add(2); list.Remove(1); var events = await eventsTask; events[0].Action.Should().Be(NotifyCollectionChangedAction.Add); events[1].Action.Should().Be(NotifyCollectionChangedAction.Add); events[2].Action.Should().Be(NotifyCollectionChangedAction.Remove); }