public void IfInputNotValidEmailReturnTrue() { var student = new StudentRegisterController(); string email = "aaal"; bool result = student.StudentValidEmail(email); Assert.IsFalse(result, "Email is incorrect and can not add in Database"); }
//add student in db and checks if info is correct void AddStudentInDb() { //NAME try { studentRegisterController.SetName(FullName); if (FullName.Split(' ').ToList().Count > 3) { throw new Exception(); } if (studentRegisterController.StudentNameExists(FullName)) { MessageBox.Show("Student already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { MessageBox.Show("Wrong Name Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Birthdate studentRegisterController.AddBirthdate(Date); //Email if (studentRegisterController.StudentValidEmail(Email)) { if (studentRegisterController.CheckEmailExists(Email)) { studentRegisterController.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 (studentRegisterController.PhoneIsValid(PhoneNumber)) { if (studentRegisterController.CheckPhoneExists(PhoneNumber) == false) { studentRegisterController.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; } //EGN if (studentRegisterController.IsValidEGN(EGN)) { if (studentRegisterController.CheckEGNExists(EGN) == false) { studentRegisterController.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 { studentRegisterController.IsValidClass(Class); } catch (Exception) { MessageBox.Show("No such class!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Class { if (studentRegisterController.IsValidClass(Class)) { studentRegisterController.SetClasses(Class); } else { MessageBox.Show("No such class!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } studentRegisterController.CommitChanged(); MessageBox.Show("Success!", "Operation Completed", MessageBoxButtons.OK); }