public void TestForParentNameIsCorrect() { var register = new ParentRegisterController(); string FullName = "Lydia Gilmore Kelley"; string EGN = "3376299241"; var result = register.ParentNameIsCorrect(FullName, EGN); Assert.IsTrue(result, "Correct perent name"); }
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); }