public void TestRemoveCorrect() { int elementId = 0; int countAfterAdd = 1; int countAfterRemove = 0; collection.Add(country); Assert.AreEqual(countAfterAdd, collection.GetCollection().Count); collection.Remove(elementId); Assert.AreEqual(countAfterRemove, collection.GetCollection().Count); }
private void ListCountry_SelectedIndexChanged(object sender, EventArgs e) { ListBox listCountry = (ListBox)sender; int currentIndex = listCountry.SelectedIndex; DialogResult dialogResult = MessageBox.Show("Удалить " + listCountry.SelectedItem.ToString() + " ?", "Подтверждение удаления", MessageBoxButtons.YesNo ); if (dialogResult == DialogResult.Yes) { try { countryCollection.Remove(currentIndex); } catch (ArgumentOutOfRangeException ex) { MessageBox.Show(ex.Message); } RefreshListCountry(); } }