public void FilterRemoveOneThenAdd() { using (var actual = this.View.SubscribeAll()) { this.View.Filter = x => x < 3; this.Scheduler?.Start(); CollectionAssert.AreEqual(new[] { 1, 2 }, this.View); var expected = new List <EventArgs>(); expected.Add(CachedEventArgs.CountPropertyChanged); expected.Add(CachedEventArgs.IndexerPropertyChanged); expected.Add(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, 3, 2)); Assert.AreEqual(1, actual.Count(x => EventArgsComparer.Equals(x, FilterChangedEventArgs))); CollectionAssert.AreEqual(expected, actual.Where(x => !EventArgsComparer.Equals(x, FilterChangedEventArgs)), EventArgsComparer.Default); this.View.Filter = x => true; this.Scheduler?.Start(); CollectionAssert.AreEqual(new[] { 1, 2, 3 }, this.View); expected.Add(CachedEventArgs.CountPropertyChanged); expected.Add(CachedEventArgs.IndexerPropertyChanged); expected.Add(Diff.CreateAddEventArgs(3, 2)); Assert.AreEqual(2, actual.Count(x => EventArgsComparer.Equals(x, FilterChangedEventArgs))); CollectionAssert.AreEqual(expected, actual.Where(x => !EventArgsComparer.Equals(x, FilterChangedEventArgs)), EventArgsComparer.Default); } }
public void FilterRemoveOne() { using var actual = this.View.SubscribeAll(); this.View.Filter = x => x < 3; this.Scheduler?.Start(); CollectionAssert.AreEqual(new[] { 1, 2 }, this.View); var expected = new List <EventArgs> { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, Diff.CreateRemoveEventArgs(3, 2), }; Assert.AreEqual(1, actual.Count(x => EventArgsComparer.Equals(x, FilterChangedEventArgs))); CollectionAssert.AreEqual(expected, actual.Where(x => !EventArgsComparer.Equals(x, FilterChangedEventArgs)), EventArgsComparer.Default); }
public void FilterReset() { using var actual = this.View.SubscribeAll(); this.View.Filter = x => x < 0; this.Scheduler?.Start(); CollectionAssert.IsEmpty(this.View); var expected = new List <EventArgs>(); expected.AddRange( new EventArgs[] { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, }); Assert.AreEqual(1, actual.Count(x => EventArgsComparer.Equals(x, FilterChangedEventArgs))); CollectionAssert.AreEqual(expected, actual.Where(x => !EventArgsComparer.Equals(x, FilterChangedEventArgs)), EventArgsComparer.Default); }