public void EmploymentDAOConstructorTest() { /*Context*/ EmploymentDAO emp_context = new EmploymentDAO(); AccountDAO account_context = new AccountDAO(); /*Insert*/ AccountDTO account = new AccountDTO(); account.userName = "******"; account.status = "active"; account.password = "******"; account.accountType = "admin"; account_context.presist(account); EmploymentDTO employment = new EmploymentDTO(); employment.company = "fuzion"; employment.country = "SA"; employment.currentEmployer = "Apple"; employment.empType = "Contract"; employment.endDate = new DateTime(2012, 12, 30); employment.gross = 10000; employment.industry = "IT"; employment.province = "WP"; employment.responsibilities = "web development"; employment.startDate = new DateTime(2012, 6, 7); employment.title = "web developer"; employment.town = "cape town"; employment.userName = "******"; emp_context.presist(employment); bool expected = true; bool actual; actual = emp_context.isFound("john", new DateTime(2012, 6, 7)); Assert.AreEqual(expected, actual); /*Update*/ employment.gross = 125000; emp_context.merge(employment); double expectedUpdate = 125000; EmploymentDTO contUpd = emp_context.find("john", new DateTime(2012, 6, 7)); Assert.AreEqual(expectedUpdate, contUpd.gross); /*Delete*/ emp_context.removeByUserId("john", new DateTime(2012, 6, 7)); bool expectedDelete = false; bool actualDelete = emp_context.isFound("john", new DateTime(2012, 6, 7)); Assert.AreEqual(expectedDelete, actualDelete); account_context.removeByUserId("john"); }
public bool isUniqueEmployment(String username, DateTime startdate) { bool isUnique = false; EmploymentDAO dao = new EmploymentDAO(); try { return (!dao.isFound(username, startdate)); } catch (InvalidOperationException ioe) { isUnique = true; } return isUnique; }