コード例 #1
0
        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");
        }
コード例 #2
0
 public bool isUniqueDisability(String username, String language)
 {
     bool isUnique = false;
     DisabilityDAO dao = new DisabilityDAO();
     try
     {
         return (!dao.isFound(username, language));
     }
     catch (InvalidOperationException ioe)
     {
         isUnique = true;
     }
     return isUnique;
 }