public void doDelete() { if (isMinimumValid()) { BasicEduDAO basicEduDao = new BasicEduDAO(); basicEduDao.removeByUserId(view.getUsername()); view.pageReload(); } else { view.showFeedback("Error Field vlaues are not valid"); } }
public void BasicEduDAOConstructorTest() { /*Context*/ BasicEduDAO edu_context = new BasicEduDAO(); AccountDAO acc_context = new AccountDAO(); /*Insert*/ AccountDTO acc = new AccountDTO(); acc.userName = "******"; acc.password = "******"; acc.accountType = "administrator"; acc.status = "active"; acc_context.presist(acc); BasicEduDTO basic_Edu = new BasicEduDTO(); basic_Edu.userName = "******"; basic_Edu.country = "South Africa"; basic_Edu.levelCompleted = 12; basic_Edu.province = "WP"; basic_Edu.school = "Brackenfell High School"; basic_Edu.town = "Cape Town"; edu_context.presist(basic_Edu); /*Update*/ basic_Edu.province = "PE"; edu_context.merge(basic_Edu); string expectedUpdate = "PE"; BasicEduDTO updateEdu = edu_context.find("john"); Assert.AreEqual(expectedUpdate, updateEdu.province); ///*Delete*/ edu_context.removeByUserId("john"); bool expectedDelBasicEdu = false; bool actualDelBasicEdu = edu_context.isFound("john"); Assert.AreEqual(expectedDelBasicEdu, actualDelBasicEdu); acc_context.removeByUserId("john"); }
public void BasicEduSubject_Test() { /*Context*/ BasicEduSubjectDAO basicEdu_context = new BasicEduSubjectDAO(); BasicEduDAO edu_context = new BasicEduDAO(); AccountDAO acc_context = new AccountDAO(); /*Insert*/ AccountDTO acc = new AccountDTO(); acc.userName = "******"; acc.password = "******"; acc.accountType = "administrator"; acc.status = "active"; acc_context.presist(acc); BasicEduDTO basic_Edu = new BasicEduDTO(); basic_Edu.userName = "******"; basic_Edu.country = "South Africa"; basic_Edu.levelCompleted = 12; basic_Edu.province = "WP"; basic_Edu.school = "Brackenfell High School"; basic_Edu.town = "Cape Town"; edu_context.presist(basic_Edu); BasicEduSubjectDTO basicEduSub = new BasicEduSubjectDTO(); basicEduSub.subjectName = "Technical Programming"; basicEduSub.subjectDescription = "Mr Kabaso is Awesome"; basicEduSub.userName = "******"; basicEdu_context.presist(basicEduSub); /*Update*/ basicEduSub.subjectDescription = "Mr Kabaso is Awesome!"; basicEdu_context.merge(basicEduSub); string expectedUpdate = "Mr Kabaso is Awesome!"; BasicEduSubjectDTO updateEduSub = basicEdu_context.find("griddy","Technical Programming"); Assert.AreEqual(expectedUpdate, updateEduSub.subjectDescription); /*Delete*/ basicEdu_context.removeByUserId("griddy", "Technical Programming"); bool expectedDelBasicEduSub = false; bool actualDelBasicEduSub = basicEdu_context.isFound("griddy", "Technical Programming"); Assert.AreEqual(expectedDelBasicEduSub, actualDelBasicEduSub); edu_context.removeByUserId("griddy"); acc_context.removeByUserId("griddy"); }