public void SetSourceNull() { using (var view = new ReadOnlySerialView <int>(new[] { 1, 2, 3 })) { using (var actual = view.SubscribeAll()) { view.SetSource(null); CollectionAssert.IsEmpty(view); var expected = new EventArgs[] { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, CachedEventArgs.GetOrCreatePropertyChangedEventArgs("Source") }; CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); } } }
public static void FromObservableOfIEnumerable() { using var subject = new Subject <IEnumerable <int> >(); using (var view = subject.AsReadOnlyView()) { using var actual = view.SubscribeAll(); subject.OnNext(new[] { 1, 2 }); CollectionAssert.AreEqual(new[] { 1, 2 }, view); var expected = new EventArgs[] { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, CachedEventArgs.GetOrCreatePropertyChangedEventArgs("Source"), }; CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); } Assert.AreEqual(false, subject.IsDisposed); }
public static void ClearSource() { var source = new ObservableCollection <int> { 1, 2, 3 }; using var view = new ReadOnlySerialView <int>(source); using var actual = view.SubscribeAll(); view.ClearSource(); CollectionAssert.IsEmpty(view); var expected = new EventArgs[] { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, CachedEventArgs.GetOrCreatePropertyChangedEventArgs("Source"), }; CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); }
public static void SetSourceNoChange() { using var view = new ReadOnlySerialView <int>(new[] { 1, 2, 3 }); using var actual = view.SubscribeAll(); view.SetSource(new[] { 1, 2, 3 }); CollectionAssert.AreEqual(new[] { 1, 2, 3 }, view); var expected = new[] { CachedEventArgs.GetOrCreatePropertyChangedEventArgs("Source") }; CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); view.SetSource(new ObservableCollection <int> { 1, 2, 3 }); CollectionAssert.AreEqual(new[] { 1, 2, 3 }, view); expected = new[] { CachedEventArgs.GetOrCreatePropertyChangedEventArgs("Source"), CachedEventArgs.GetOrCreatePropertyChangedEventArgs("Source"), }; CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); }