public void IfParentEgnNotExistsInDb() { var parent = new ParentRegisterController(); string EGN = "3333333333"; bool result = parent.CheckEGNExists(EGN); Assert.IsFalse(result, "This Parent EGN not exists in Database"); }
public void IfParentEgnExistsInDb() { var parent = new ParentRegisterController(); string EGN = "0123456789"; bool result = parent.CheckEGNExists(EGN); Assert.IsTrue(result, "This Parent EGN exists in Database"); }
private void AddParentInDb() { // NAME try { parentRegisterController.SetName(FullName); if (FullName.Split(' ').ToList().Count > 3) { throw new Exception(); } if (parentRegisterController.ParentNameExists(FullName)) { MessageBox.Show("Parent already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception) { MessageBox.Show("Wrong Name Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // EGN if (parentRegisterController.IsValidEGN(EGN)) { if (parentRegisterController.CheckEGNExists(EGN) == false) { parentRegisterController.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; } // Lydia Gilmore Kelley // 3376299241 // STUDENT EGN if (parentRegisterController.IsValidEGN(StudentEGN)) { if (parentRegisterController.CheckStudentEGNExists(StudentEGN)) { parentRegisterController.SetStudentEGN(StudentEGN); } else { MessageBox.Show("No such student EGN!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Student EGN is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // STUDENT NAME try { var test = StudentName.Split(' ').ToList(); if (test.Count != 3) { throw new Exception(); } else if (parentRegisterController.ParentNameIsCorrect(StudentName, StudentEGN)) { parentRegisterController.SetStudentName(StudentName); } else { MessageBox.Show("No such student!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception) { MessageBox.Show("Wrong student name format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } parentRegisterController.AddParent(); MessageBox.Show("Success!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); }