/// <summary> /// Updates a student record. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { StudentEntity student = new StudentEntity(); if (txtId.Text != string.Empty) { student.Id = Convert.ToInt32(txtId.Text); if (txtName.Text != string.Empty) { student.Name = txtName.Text; if (txtAge.Text != string.Empty) { student.Age = Convert.ToInt32(txtAge.Text); student.Gender = radioGender1.Checked ? 'M' : 'F'; CheckStudentValidations studentValidations = new CheckStudentValidations(); if (studentValidations.UpdateStudent(student) != 0) { MessageBox.Show("Student Data updated Successfully", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ClearFields(); txtId.Enabled = false; } else { MessageBox.Show("Error Occured while save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Fill Age!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtId.Enabled = false; } } else { MessageBox.Show("Fill Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtId.Enabled = false; } } else { MessageBox.Show("Please first search the student you want to update", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); txtId.Enabled = false; } }
public void ShouldUpdateStudent(StudentEntity student) { var result = sut.UpdateStudent(student); Assert.That(result, Is.EqualTo(1)); }