public void doDelete() { if (isMinimumValid()) { DisabilityDAO disabilityDao = new DisabilityDAO(); disabilityDao.removeByUserId(view.getUsername(), view.getDisabilityType()); view.pageReload(); } else { view.showFeedback("Error Field vlaues are not valid"); } }
public void DisabilityDAOConstructorTest() { /*Context*/ DisabilityDAO disability_context = new DisabilityDAO(); AccountDAO account_context = new AccountDAO(); /*Insert*/ AccountDTO account = new AccountDTO(); account.userName = "******"; account.status = "active"; account.password = "******"; account.accountType = "admin"; account_context.presist(account); DisabilityDTO disability = new DisabilityDTO(); disability.disabilityType = "hearing"; disability.description = "loss of hearing"; disability.userName = "******"; disability_context.presist(disability); bool expected = true; bool actual; actual = disability_context.isFound("john", "hearing"); Assert.AreEqual(expected, actual); /*Update*/ disability.description = "no hearing"; disability_context.merge(disability); string expectedUpdate = "no hearing"; DisabilityDTO contUpd = disability_context.find("john", "hearing"); Assert.AreEqual(expectedUpdate, contUpd.description); /*Delete*/ disability_context.removeByUserId("john", "hearing"); bool expectedDelete = false; bool actualDelete = disability_context.isFound("john", "hearing"); Assert.AreEqual(expectedDelete, actualDelete); account_context.removeByUserId("john"); }