public void controllerTest() { controller.add("1", "name", "1231231231", "ab"); Assert.AreEqual(controller.getAll().Count, 1); controller.update("1", "1", "name name", "1231231231", "ab"); Candidate c = controller.getById("1"); Assert.AreEqual(c.Name, "name name"); }
/* * Updates a candidate */ private void buttonUpdate_Click(object sender, EventArgs e) { if (listBoxCandidate.SelectedIndex != -1) { try { Candidate candidate = (Candidate)listBoxCandidate.SelectedItem; controller.update(candidate.Id.ToString(), textBoxId.Text, textBoxName.Text, textBoxTelephone.Text, textBoxAddress.Text); } catch (ValidatorException exc) { System.Windows.Forms.MessageBox.Show(exc.Message); } catch (RepositoryException exc) { System.Windows.Forms.MessageBox.Show(exc.Message); } } else { System.Windows.Forms.MessageBox.Show("You must select a candidate."); } }