private void buttonAddCentruT_Click(object sender, EventArgs e) { //add centru transfuzie string nume, parola, adresa, judet, localitate; nume = textBoxNume.Text; adresa = textBoxAdresa.Text; parola = textBoxParola.Text; if (comboBoxJudet.SelectedIndex >= 0 && comboBoxLocalitate.SelectedIndex >= 0) { judet = comboBoxJudet.Items[comboBoxJudet.SelectedIndex].ToString(); localitate = comboBoxLocalitate.Items[comboBoxLocalitate.SelectedIndex].ToString(); if (nume.Equals("") || parola.Equals("") || adresa.Equals("")) { MessageBox.Show(this, "Campuri necompletate!", "Error!"); } else { //adaugare CentruTransfuzie centru = new CentruTransfuzie(nume, adresa, localitate, judet, parola); adminService.AddCentru(centru); loadDataGridViewCentreT(); loadComboBoxCentreTranfuzii(); } } else { MessageBox.Show(this, "Campuri necompletate!", "Error!"); } }
public void TestAddCentru() { int count = adminService.GetAllCentre().Count; CentruTransfuzie centru = new CentruTransfuzie("CentruTest", "Test", "Test", "Test", "Test"); adminService.AddCentru(centru); Assert.AreEqual(count + 1, adminService.GetAllCentre().Count); try { adminService.AddCentru(centru); } catch (Exception e) { Assert.AreEqual(count + 1, adminService.GetAllCentre().Count); } adminService.Delete(centru); Assert.AreEqual(count, adminService.GetAllCentre().Count); }