public void HigherEducation_Test() { /*Context*/ HigherEducationDAO higher_context = new HigherEducationDAO(); AccountDAO account_context = new AccountDAO(); /*Insert*/ AccountDTO account = new AccountDTO(); account.userName = "******"; account.status = "active"; account.password = "******"; account.accountType = "admin"; account_context.presist(account); HigherEducationDTO higherEdu = new HigherEducationDTO(); higherEdu.userName = "******"; higherEdu.country = "SA"; higherEdu.educationType = "BTECH"; higherEdu.industry = "Information Technology"; higherEdu.institution = "CPUT"; higherEdu.length = "four years"; higherEdu.major = "Technical Programming"; higherEdu.nqf = "7"; higherEdu.province = "WP"; higherEdu.town = "Cape Town"; higher_context.presist(higherEdu); bool expected = true; bool actual; actual = higher_context.isFound("griddy", "Technical Programming"); Assert.AreEqual(expected, actual); /*Update*/ higherEdu.institution = "UWC"; higher_context.merge(higherEdu); string expectedUpdate = "UWC"; HigherEducationDTO contUpd = higher_context.find("griddy", "Technical Programming"); Assert.AreEqual(expectedUpdate, contUpd.institution); /*Delete*/ higher_context.removeByUserId("griddy", "Technical Programming"); bool expectedDelete = false; bool actualDelete = higher_context.isFound("griddy", "Technical Programming"); Assert.AreEqual(expectedDelete, actualDelete); account_context.removeByUserId("griddy"); }
public bool isUniqueHigherEducation(String username, String major) { bool isUnique = false; HigherEducationDAO dao = new HigherEducationDAO(); try { return (!dao.isFound(username, major)); } catch (InvalidOperationException ioe) { isUnique = true; } return isUnique; }