public void RemoveElementTest() { Company company = new Company("ООО НИЛЬС", "ООО НИЛЬС", "000000001", "ООО"); Company company1 = new Company("LLC Vesta", "LLC Vesta", "000000002", "LLC"); CompanyDataController companyDataController = new CompanyDataController(company); companyDataController.AddElement(company1); Assert.AreEqual(2, companyDataController.Count); companyDataController.RemoveElement(company); Assert.AreEqual(1, companyDataController.Count); Assert.AreEqual(company1, companyDataController.GetCurrentElement()); }
private void deleteCompanyButton_Click(object sender, EventArgs e) { if (companyDataGridView.SelectedRows.Count > 0) { int index = companyDataGridView.SelectedRows[0].Index; int id; bool converted = int.TryParse(companyDataGridView[0, index].Value.ToString(), out id); if (!converted) { return; } var element = from t in controller.Elements where t.ID == id select t; controller.RemoveElement(element.First()); companyDataGridView.DataSource = controller.Elements; } }