public void RemoveAt_triggers_CollectionChanged() { var sut = new EventRaisingList <Person> (_source); NotifyCollectionChangedEventArgs capturedArgs = default; void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) => capturedArgs = args; sut.CollectionChanged += OnCollectionChanged; sut.RemoveAt(1); sut.CollectionChanged -= OnCollectionChanged; Assert.That(capturedArgs, Is.Not.Null); }
public void RemoveAt_includes_index_of_removed_item() { var sut = new EventRaisingList <Person> (_source); AfterModifyEventArgs <Person> capturedArgs = default; void OnAfterRemove(object sender, AfterModifyEventArgs <Person> args) => capturedArgs = args; sut.AfterRemove += OnAfterRemove; sut.RemoveAt(1); sut.AfterRemove -= OnAfterRemove; Assert.That(capturedArgs, Is.InstanceOf <AfterModifyListEventArgs <Person> >().And.Property(nameof(IHasListIndex.Index)).EqualTo(1)); }
public void RemoveAt_triggers_both_remove_events() { // Arrange var sut = new EventRaisingList <Person> (_source); sut.BeforeRemove += RecordingCallbackOne; sut.AfterRemove += RecordingCallbackTwo; // Act sut.RemoveAt(1); sut.BeforeRemove -= RecordingCallbackOne; sut.AfterRemove -= RecordingCallbackTwo; // Assert Assert.IsTrue(CallbackOneCalled, "Callback one"); Assert.IsTrue(CallbackTwoCalled, "Callback two"); }