public void ClearOne() { var before = new[] { 1 }; var ints = new ObservableCollection <int>(before); ints.Clear(); var actual = Diff.CollectionChange(new[] { 1 }, ints); AssertEx.AreEqual(Diff.CreateRemoveEventArgs(1, 0), actual); }
public void NoChangeNoEvent() { var change = Diff.CollectionChange(new[] { 1, 2, 3 }, new[] { 1, 2, 3 }); var notifier = new DummyNotifier(); var actual = notifier.SubscribeAll(); Notifier.Notify(notifier, change, null, notifier.PropertyChangedEventHandler, notifier.NotifyCollectionChangedEventHandler); CollectionAssert.IsEmpty(actual); }
public void RemoveLast() { var before = new[] { 1 }; var ints = new ObservableCollection <int>(before); var expected = ints.CollectionChange(); ints.Remove(1); var actual = Diff.CollectionChange(before, ints); AssertEx.AreEqual(expected.Value, actual); }
public void Insert(int index) { var before = new[] { 1, 2, 3 }; var ints = new ObservableCollection <int>(before); var expected = ints.CollectionChange(); ints.Insert(index, 4); var actual = Diff.CollectionChange(before, ints); AssertEx.AreEqual(expected.Value, actual); }
public void AddToEmpty() { var ints = new ObservableCollection <int>(); var expected = ints.CollectionChange(); ints.Add(1); var actual = Diff.CollectionChange(new int[0], ints); AssertEx.AreEqual(expected.Value, actual); }
public void Replace() { var before = new[] { 1, 2, 3 }; var ints = new ObservableCollection <int>(before); var expected = ints.CollectionChange(); ints[0] = 5; var actual = Diff.CollectionChange(before, ints); AssertEx.AreEqual(expected.Value, actual); }
public void AddRefType() { var before = new[] { new Fake(), new Fake(), new Fake() }; var ints = new ObservableCollection <Fake>(before); var expected = ints.CollectionChange(); ints.Add(new Fake()); var actual = Diff.CollectionChange(before, ints); AssertEx.AreEqual(expected.Value, actual); }
public void Remove(int index) { var before = new[] { 1, 2, 3 }; var ints = new ObservableCollection <int>(before); var expected = ints.SubscribeAll(); var notifier = new DummyNotifier(); var actual = notifier.SubscribeAll(); ints.RemoveAt(index); var change = Diff.CollectionChange(before, ints); Notifier.Notify(notifier, change, null, notifier.PropertyChangedEventHandler, notifier.NotifyCollectionChangedEventHandler); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); }
public void AddToEmpty() { var ints = new ObservableCollection <int>(); var expected = ints.SubscribeAll(); ints.Add(1); var notifier = new DummyNotifier(); var actual = notifier.SubscribeAll(); var change = Diff.CollectionChange(new int[0], ints); Notifier.Notify(notifier, change, null, notifier.PropertyChangedEventHandler, notifier.NotifyCollectionChangedEventHandler); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); }
public void NoChange() { var actual = Diff.CollectionChange(new[] { 1, 2, 3 }, new[] { 1, 2, 3 }); Assert.IsNull(actual); }