public void IfTeahcerNameNotExistsInDatabase() { var teacher = new TeacherRegisterController(); string FullName = "AAAAAA BBBBBBB CCCCCCC"; bool result = teacher.TeacherNameExists(FullName); Assert.IsFalse(result, "This name does not exist and can be added in Database"); }
public void IfTeahcerNameExistsInDatabase() { var teacher = new TeacherRegisterController(); string FullName = "Joyce Greer Wood"; bool result = teacher.TeacherNameExists(FullName); Assert.IsTrue(result, "This name exists and can not be added in Database"); }
//add teacher in db and checks if info is correct void AddTeacherInDb() { //NAME try { teacherRegisterController.SetName(FullName); if (FullName.Split(' ').ToList().Count > 3) { throw new Exception(); } if (teacherRegisterController.TeacherNameExists(FullName)) { MessageBox.Show("Teacher already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { MessageBox.Show("Wrong Name Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // ADD BirthDate teacherRegisterController.AddBirthdate(Date); //Email if (teacherRegisterController.IsValidEmail(Email)) { if (teacherRegisterController.CheckEmailExists(Email)) { teacherRegisterController.SetEmail(Email); } else { MessageBox.Show("Email is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Email is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //ADD Phone if (teacherRegisterController.PhoneIsValid(PhoneNumber)) { if (teacherRegisterController.CheckPhoneExists(PhoneNumber) == false) { teacherRegisterController.SetPhone(PhoneNumber); } else { MessageBox.Show("Phone number is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Phone number is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //ADD EGN if (teacherRegisterController.IsValidEGN(EGN)) { if (teacherRegisterController.CheckEGNExists(EGN) == false) { teacherRegisterController.SetEGN(EGN); } else { MessageBox.Show("EGN is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("EGN is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { if (Subject.SelectedItem == null) { MessageBox.Show("Please select a subject!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { teacherRegisterController.SetSubject(Subject.Text); } } catch (Exception) { MessageBox.Show("Please select a subject!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } teacherRegisterController.CommitChanged(); MessageBox.Show("Success!", "Operation Completed", MessageBoxButtons.OK); }