public void RemoveItems() { BaseCollection <int> collection = new BaseCollection <int>(new [] { 1, 2, 3 }); collection.Remove(3); collection.Remove(2); Assert.AreEqual(1, collection.Count()); Assert.AreEqual(1, collection[0]); }
/// <summary> /// <see cref="IDictionary{TKey, TValue}.Remove(TKey)" /> /// </summary> public bool Remove(TKey key) { var oldValue = TryGetOldValue(key); var result = BaseCollection.Remove(key); if (result) { RaiseCollectionEvents(); var e = new NotifyCollectionChangedEventArgs(action: NotifyCollectionChangedAction.Remove, changedItem: oldValue); RaiseCollectionChanged(e); } return(result); }
public void CallEvents() { BaseCollection <int> collection = new BaseCollection <int>(); var setSubscriber = Substitute.For <IDummyEventSubscriber <IEnumerable <int> > >(); var addedSubscriber = Substitute.For <IDummyEventSubscriber <int> >(); var removedSubscriber = Substitute.For <IDummyEventSubscriber <int> >(); collection.OnSet += setSubscriber.React; collection.OnAdded += addedSubscriber.React; collection.OnRemoved += removedSubscriber.React; collection.Set(new [] { 1, 2, 3, 4 }); collection.Add(4); collection.Remove(2); collection.RemoveAt(0); setSubscriber.Received().React(collection.list); addedSubscriber.Received().React(4); removedSubscriber.Received().React(2); removedSubscriber.Received().React(1); }
private void btnDelTypeEquipment_Click(object sender, RoutedEventArgs e) { typeEquipments.Remove((TypeEquipmentView)gridTypeEquipment.SelectedItem); gridTypeEquipment.Items.Refresh(); gridTypeEquipment.ItemsSource = typeEquipments; }
private void btnDelEquipment_Click(object sender, RoutedEventArgs e) { equipments.Remove((EquipmentView)gridEquipment.SelectedItem); gridEquipment.Items.Refresh(); }