protected void Button1_Click(object sender, EventArgs e)
        {
            AccountDAO context = new AccountDAO();
            AccountDTO acc = new AccountDTO();
            if (!context.isFound("skippy"))
                Label1.Text = "Not found";
            else
                Label1.Text = "Found";
            acc.userName = null;
            acc.password = "******";
            acc.accountType = "admin";
            acc.status = "active";

            context.presist(acc);

            acc.userName = "******";

            if( !   context.presist(acc) )
                Label2.Text = "Error";
            else
                Label2.Text = "OK";

            //if(context.isFound("skippy"))
            //    text = "found";
            //else
            //TextBox1.Text = "not found";
        }
        public void AccountDAO_Test()
        {
            /*Context*/
            AccountDAO target = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            string userName = "******"; // TODO: Initialize to an appropriate value
            Assert.AreEqual(false, target.isFound(userName));
            Assert.AreEqual(true,target.presist(acc));

            Assert.AreEqual(true, target.isFound(userName));//

            /*Update*/
            acc.status = "inactive";
            target.merge(acc);

            string expectedUpdate = "inactive";
            AccountDTO upd =  target.find("griddy");
            Assert.AreEqual(expectedUpdate, upd.status);

            /*Delete*/
            Assert.AreEqual(false, target.removeByUserId("griddy"));
        }
        public void SupportDocDAOConstructorTest()
        {
            /*context*/
            SupportDocDAO sup_context = new SupportDocDAO(); // TODO: Initialize to an appropriate value
            AccountDAO acc_context = new AccountDAO();
            /*insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            SupportDocDTO supp = new SupportDocDTO();
            supp.userName = "******";
            byte[] bits = { 1, 0, 1, 0, 0, 1 };
            supp.content = bits;
            supp.description = "Supporting doc";
            supp.title = "help";

            sup_context.presist(supp);
            Assert.AreEqual(supp.title, sup_context.find("john", "help").title);
            /*Update*/
            supp.description = "NEW doc";
            sup_context.merge(supp);
            Assert.AreEqual("NEW doc", sup_context.find("john", "help").description);

            /*Delete*/
            sup_context.removeByUserId("john", "help");
            Assert.AreEqual(sup_context.isFound("john", "help"), false);
            acc_context.removeByUserId("john");
        }
        public void LicenseDAOConstructorTest()
        {
            /*Context*/
            AccountDAO acc_context = new AccountDAO();
            LicenseDAO lic_context = new LicenseDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            LicenseDTO lic = new LicenseDTO();
            lic.userName = "******";
            lic.type = "car";

            lic_context.presist(lic);
            Assert.AreEqual(lic.type, lic_context.find("john","car").type);

            /*Update*/
            //N/A

            /*Delete*/
            lic_context.removeByUserId("john","car");
            Assert.AreEqual(lic_context.isFound("john","car"), false);

            acc_context.removeByUserId("john");
        }
        public void ApplicationDAO_Test()
        {
            AccountDAO account_context = new AccountDAO();
            ApplicationDAO app_context = new ApplicationDAO();
            VacancyDAO vac_context = new VacancyDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            VacancyDTO vac = new VacancyDTO();
            vac.department = "IS";
            vac.description = "Web services";
            vac.manager = "Tom";
            vac.recruiter = "Thumi";
            vac.site = "www.petrosa.co.za";
            vac.startDate = new DateTime(2012, 10, 10);
            vac.endDate = new DateTime(2012, 12, 1);
            vac.description = "desktop support";
            vac.title = "support technician";
            vac.vacancyNumber = "1";
            vac.viewCount = 10;
            vac.viewStatus = "published";
            vac.status = "active";

            vac_context.presist(vac);
            bool expectedVac = true;
            bool actualVac;
            actualVac = vac_context.isFound("1");
            Assert.AreEqual(expectedVac, actualVac);

            ApplicationDTO application = new ApplicationDTO();
            application.userName = "******";
            application.vacancyNumber = "1";
            application.status = "open";

            app_context.presist(application);
            bool expected = true;
            bool actual;
            actual = app_context.isFound("griddy", "1");
            Assert.AreEqual(expected, actual);

            /*Update*/
            application.status = "closed";
            expected = true;
            actual = app_context.merge(application);
            Assert.AreEqual(expected, actual);

            /*Delete*/
            Assert.AreEqual(app_context.removeByUserId("griddy", "1"), true);
            Assert.AreEqual(vac_context.removeByUserId("1"), true);
            Assert.AreEqual(account_context.removeByUserId("griddy"), true);
        }
        public void inboxMessagesTest()
        {
            InboxService inboxService = new InboxServiceImpl();

            /*Context*/
            InboxDAO inbox_context = new InboxDAO();
            AccountDAO account_context = new AccountDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            InboxDTO inbox = new InboxDTO();
            inbox.date = new DateTime(2012, 9, 30);
            inbox.message = "success";
            inbox.messageId = 1;
            inbox.unread = "unread";
            inbox.userName = "******";

            inbox_context.presist(inbox);

            bool expected = true;
            bool actual;
            actual = inbox_context.isFound("griddy", 1);
            Assert.AreEqual(expected, actual);

            //Test getInboxMessagesByDate method
            Assert.AreEqual(true, inboxService.hasUnreadMessage("griddy"));

            //Test getInboxMessagesByMessage method
            int inboxMessageNumber = inboxService.getNumberOfInboxMessages("griddy");
            Assert.AreEqual(1, inboxMessageNumber);

            //Test setMessagesRead method
            inboxService.setMessagesRead("griddy", 1);
            InboxMessageSearchService inboxSearchService = new InboxMessageSearchServiceImpl();
            List<InboxDTO> inboxDtoList = inboxSearchService.getInboxMessagesByUsername("griddy");

            Assert.AreEqual("read", inboxDtoList[0].unread);
            inboxDtoList.RemoveRange(0, inboxDtoList.Count);
            inboxDtoList = null;
            inbox = null;

            /*Delete*/
            inbox_context = new InboxDAO();
            inbox_context.removeByUserId("griddy", 1);
            bool expectedDelete = false;
            bool actualDelete = inbox_context.isFound("griddy", 1);
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
        public void securityServiceTest()
        {
            SecurityService sercutiryService = CreateSecurityService(); // TODO: Initialize to an appropriate value

            /*Context*/
            AccountDAO target = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = AccountType.USER.ToString();
            acc.status = "active";

            target.presist(acc);

            string username = "******"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.isFound(username);
            Assert.AreEqual(expected, actual);

            //sercutiryService.resetPassword(username);

            sercutiryService.lockAccount(username);
            target = new AccountDAO();
            AccountDTO account = target.find(username);
            Assert.AreEqual(AccountStatus.LOCKED.ToString(), account.status);

            sercutiryService.activateAccount(username);
            target = new AccountDAO();
            AccountDTO account2 = target.find(username);
            Assert.AreEqual(AccountStatus.ACTIVE.ToString(), account2.status);

            sercutiryService.setUserRole(username, AccountType.MANAGER);
            target = new AccountDAO();
            AccountDTO account3 = target.find(username);
            Assert.AreEqual(AccountType.MANAGER.ToString(), account3.accountType);

            sercutiryService.requestAccountUnlock(username);
            target = new AccountDAO();
            AccountDTO account4 = target.find(username);
            Assert.AreEqual(AccountStatus.UNLOCKED.ToString(), account4.status);

            sercutiryService.setAccountActive(username);
            target = new AccountDAO();
            AccountDTO account5 = target.find(username);
            Assert.AreEqual(AccountStatus.ACTIVE.ToString(), account5.status);

            /*Delete*/
            target.removeByUserId("griddy");
            bool expectedDelete = false;
            bool actualDelete = target.isFound("griddy");
            Assert.AreEqual(expectedDelete, actualDelete);
        }
        public void EmploymentDAO_Test()
        {
            /*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("griddy", 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("griddy", new DateTime(2012, 6, 7));
            Assert.AreEqual(expectedUpdate, contUpd.gross);

            /*Delete*/
            emp_context.removeByUserId("griddy", new DateTime(2012, 6, 7));
            bool expectedDelete = false;
            bool actualDelete = emp_context.isFound("griddy", new DateTime(2012, 6, 7));
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
        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 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");
        }
        public void UserDAO_Test()
        {
            /*Context*/
            AccountDAO acc_context = new AccountDAO();
            UserDAO user_context = new UserDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            UserDTO user = new UserDTO();
            user.basicEducation = true;
            user.citizenship = true;
            user.disabled = true;
            user.employed = true;
            user.employmentHistory = true;
            user.fullName = "Andre";
            user.gender = "male";
            user.higherEducation = true;
            user.id = "8630302930";
            user.idType = "SA";
            user.language = true;
            user.license = true;
            user.nickName = "WIlliem";
            user.postalAddress = true;
            user.race = "white";
            user.residentialAddress = true;
            user.surname = "Pretorious";
            user.userName = "******";

              //  user_context.presist(user);
            //Assert.AreEqual(user.race, user_context.find("griddy","8630302930").race);

            ///*Update*/
            //user.nickName = "willi";
            //user_context.merge(user);
            //Assert.AreEqual(user.nickName, user_context.find("griddy", "8630302930").nickName);

            ///*Delete*/
            //user_context.removeByUserId("griddy", "8630302930");
            //Assert.AreEqual(user_context.isFound("griddy", "8630302930"), false);

            acc_context.removeByUserId("griddy");
        }
        public void InboxDAOConstructorTest()
        {
            /*Context*/
            InboxDAO inbox_context = new InboxDAO();
            AccountDAO account_context = new AccountDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            InboxDTO inbox = new InboxDTO();
            inbox.date = new DateTime(2012, 9, 30);
            inbox.message = "success";
            inbox.vacancyNumber = "1";
            inbox.unread = "read";
            inbox.userName = "******";
            inbox.status = "applied";

            inbox_context.presist(inbox);

            bool expected = true;
            bool actual;
            actual = inbox_context.isFound("john", "1");
            Assert.AreEqual(expected, actual);

            /*Update*/
            inbox.unread = "not read";
            inbox_context.merge(inbox);
            string expectedUpdate = "not read";
            InboxDTO contUpd = inbox_context.find("john", "1");
            Assert.AreEqual(expectedUpdate, contUpd.unread);

            /*Delete*/
            inbox_context.removeByUserId("john", "1");
            bool expectedDelete = false;
            bool actualDelete = inbox_context.isFound("john", "1");
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("john");
        }
        public void ContactInfo_Test()
        {
            /*Context*/
            ContactInfoDAO contactInfo_context = new ContactInfoDAO();
            AccountDAO acc_context = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            ContactInfoDTO contact = new ContactInfoDTO();
            contact.userName = "******";
            contact.contactType = "skype";
            contact.data = "skippy";

            contactInfo_context.presist(contact);

            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = contactInfo_context.isFound("griddy", "skype");
            Assert.AreEqual(expected, actual);

            /*Update*/
            contact.data = "Gready";
            contactInfo_context.merge(contact);

            string expectedUpdate = "Gready";
            ContactInfoDTO contUpd = contactInfo_context.find("griddy", "skype");
            Assert.AreEqual(expectedUpdate, contUpd.data);

            /*Delete*/
            contactInfo_context.removeByUserId("griddy", "skype");

            bool expectedDelete = false;
            bool actualDelete = contactInfo_context.isFound("griddy", "skype");
            Assert.AreEqual(expectedDelete, actualDelete);

            acc_context.removeByUserId("griddy");
        }
        public void Disability_Test()
        {
            /*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("griddy", "hearing");
            Assert.AreEqual(expected, actual);

            /*Update*/
            disability.description = "no hearing";
            disability_context.merge(disability);
            string expectedUpdate = "no hearing";
            DisabilityDTO contUpd = disability_context.find("griddy", "hearing");
            Assert.AreEqual(expectedUpdate, contUpd.description);

            /*Delete*/
            disability_context.removeByUserId("griddy", "hearing");

            bool expectedDelete = false;
            bool actualDelete = disability_context.isFound("griddy", "hearing");
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
        public void AddressDAO_Test()
        {
            /*Context*/
            AccountDAO acc_context = new AccountDAO();
            AddressDAO address_context = new AddressDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            AddressDTO address = new AddressDTO();
            address.userName = "******";
            address.addressType = "postal";
            address.country = "South Africa";
            address.province = "WP";
            address.street = "Frans";
            address.suburb = "Parow";
            address.town = "Cape Town";
            address.unitNumber = 22;

            address_context.presist(address);
            /*Update*/
            address.town = "Pretoria";
            address_context.merge(address);

            string expectedUpdate = "Pretoria";
            AddressDTO upd = address_context.find("griddy", "postal");
            Assert.AreEqual(expectedUpdate, upd.town);

            /*Delete*/
            address_context.removeByUserId("griddy", "postal");
            bool expectedDelAddress = false;
            bool actualDeleteAddress = address_context.isFound("griddy", "postal");
            Assert.AreEqual(expectedDelAddress, actualDeleteAddress);

            acc_context.removeByUserId("griddy");
        }
        public void BasicEduDAO_Test()
        {
            /*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("griddy");
            Assert.AreEqual(expectedUpdate, updateEdu.province);

            ///*Delete*/
            edu_context.removeByUserId("griddy");
            bool expectedDelBasicEdu = false;
            bool actualDelBasicEdu = edu_context.isFound("griddy");
            Assert.AreEqual(expectedDelBasicEdu, actualDelBasicEdu);

            acc_context.removeByUserId("griddy");
        }
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            // Determine the currently logged on user's UserId
            //MembershipUser currentUser = Membership.GetUser();
            //Guid currentUserId = (Guid)currentUser.ProviderUserKey;

            //Create user in Account table
            DAO_Account_Interface acc_ctx = new AccountDAO();
            AccountDTO newAccount = new AccountDTO();

            newAccount.userName = CreateUserWizard1.UserName.ToLower();
            newAccount.password = "******";
            newAccount.status = "active";
            newAccount.accountType = "user";
            acc_ctx.presist(newAccount);

            //Add User Email to COntact Info
            DAO_ContactInfo_Interface info_ctx = new ContactInfoDAO();
            ContactInfoDTO mail_info = new ContactInfoDTO();
            mail_info.userName = newAccount.userName;
            mail_info.contactType = "e-mail";
            mail_info.data = CreateUserWizard1.Email;
            info_ctx.presist(mail_info);

            //Add User information to User Table
            DAO_User_Interface user_ctx = new UserDAO();
            UserDTO user_info = new UserDTO();
            user_info.userName = newAccount.userName;
            user_info.id = txtID.Text;
            user_info.fullName = txtName.Text;
            user_info.surname = txtSurname.Text;
            user_info.nickName = txtNickname.Text;
            user_info.idType = RadioIdType.SelectedValue;
            user_info.race = RadioRace.SelectedValue;
            user_info.gender = RadioGender.SelectedValue;
            user_ctx.presist(user_info);

            Roles.AddUserToRole(newAccount.userName, "User");
        }
        public void LanguageDAO_Test()
        {
            LanguageDAO lang_context = new LanguageDAO();
            AccountDAO acc_context = new AccountDAO();

            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            LanguageDTO lang = new LanguageDTO();
            lang.userName = "******";
            lang.languageName = "english";
            lang.speak = "no";
            lang.write = "Yes";
            lang.reads = "Yes";

            lang_context.presist(lang);
            Assert.AreEqual("no", lang_context.find("griddy", "english").speak);

            /*Update*/
            /*lang.speak = "X";
            lang_context.merge(lang);
            string str = lang_context.find("griddy", "english").speak;
            //Assert.AreEqual("X", str);

            /*Delete*/
            lang_context.removeByUserId("griddy", "english");
            Assert.AreEqual(false, lang_context.isFound("griddy", "english"));

            acc_context.removeByUserId("griddy");
        }
        public void LanguageDAOConstructorTest()
        {
            /*Context*/
            LanguageDAO lang_context = new LanguageDAO();
            AccountDAO acc_context = new AccountDAO();

            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            LanguageDTO lang = new LanguageDTO();
            lang.userName = "******";
            lang.languageName = "english";
            lang.speak = "Yes";
            lang.write = "Yes";
            lang.reads = "Yes";

            lang_context.presist(lang);
            Assert.AreEqual(lang.speak, lang_context.find("john", "english").speak);

            /*Update*/
            lang.speak = "No";
            lang_context.merge(lang);
            Assert.AreEqual("No", lang_context.find("john", "english").speak);

            /*Delete*/
            lang_context.removeByUserId("john", "english");
            Assert.AreEqual(lang_context.isFound("john", "english"), false);

            acc_context.removeByUserId("john");
        }
        public void applicationSearchServiceTest()
        {
            ApplicationSearchService target = new ApplicationSearchServiceImpl(); // TODO: Initialize to an appropriate value

            AccountDAO account_context = new AccountDAO();
            ApplicationDAO app_context = new ApplicationDAO();
            VacancyDAO vac_context = new VacancyDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";
            account_context.presist(account);

            VacancyDTO vac = new VacancyDTO();
            vac.department = "IS";
            vac.description = "Web services";
            vac.manager = "Tom";
            vac.recruiter = "Thumi";
            vac.site = "www.petrosa.co.za";
            vac.startDate = new DateTime(2012, 10, 10);
            vac.endDate = new DateTime(2012, 12, 1);
            vac.description = "desktop support";
            vac.title = "support technician";
            vac.vacancyNumber = "1";
            vac.viewCount = 10;
            vac.viewStatus = "published";
            vac.status = "active";

            vac_context.presist(vac);
            bool expectedVac = true;
            bool actualVac;
            actualVac = vac_context.isFound("1");
            Assert.AreEqual(expectedVac, actualVac);

            ApplicationDTO application = new ApplicationDTO();
            application.userName = "******";
            application.vacancyNumber = "1";
            application.status = "open";
            app_context.presist(application);

            //Test getApplicationByUsername method
            List<ApplicationDTO> applicationTestListObj = target.getApplicationByUsername("graddy");
            Assert.AreEqual(application.status, applicationTestListObj[0].status);

            //Test getApplicationByStatus method
            List<ApplicationDTO> applicationTestListObj2 = target.getApplicationByStatus("open");
            Assert.AreEqual(application.status, applicationTestListObj2[0].status);

            //Test getApplicationByVacancyNumber method
            List<ApplicationDTO> applicationTestListObj3 = target.getApplicationByVacancyNumber("1");
            Assert.AreEqual(application.status, applicationTestListObj3[0].status);

            /*Delete*/
            /*
            account_context.removeByUserId("graddy");
            bool expectedDelete = false;
            bool actualDelete = account_context.isFound("graddy");
            Assert.AreEqual(expectedDelete, actualDelete);
            */
        }
        public void userServiceTest()
        {
            UserService target = CreateUserService(); // TODO: Initialize to an appropriate value

            AccountDAO account_context = new AccountDAO();
            ApplicationDAO app_context = new ApplicationDAO();
            VacancyDAO vac_context = new VacancyDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            VacancyDTO vac = new VacancyDTO();
            vac.department = "IS";
            vac.description = "Web services";
            vac.manager = "Tom";
            vac.recruiter = "Thumi";
            vac.site = "www.petrosa.co.za";
            vac.startDate = new DateTime(2012, 10, 10);
            vac.endDate = new DateTime(2012, 12, 1);
            vac.description = "desktop support";
            vac.title = "support technician";
            vac.vacancyNumber = "1";
            vac.viewCount = 10;
            vac.viewStatus = "published";
            vac.status = "active";

            vac_context.presist(vac);
            bool expectedVac = true;
            bool actualVac;
            actualVac = vac_context.isFound("1");
            Assert.AreEqual(expectedVac, actualVac);

            ApplicationDTO applicationDto = new ApplicationDTO();
            applicationDto.userName = "******";
            applicationDto.vacancyNumber = "1";
            applicationDto.status = ApplicationStatus.APPLIED.ToString();

            app_context.presist(applicationDto);
            bool expected = true;
            bool actual;
            actual = app_context.isFound("griddy", "1");
            Assert.AreEqual(expected, actual);

            //Test changeUserApplicationStatus method
            target.changeUserApplicationStatus("griddy", "1", ApplicationStatus.SHORTLISTED);
            ApplicationDTO applicationDto2 = app_context.find("griddy", "1");
            Assert.AreEqual(ApplicationStatus.SHORTLISTED.ToString(), applicationDto2.status);

            //Test getShortListedCandidates method
            List<ApplicationDTO> candidates = target.getShortListedCandidates("1");
            Assert.AreEqual("griddy", candidates[0].userName);

            /*Delete*/
            Assert.AreEqual(app_context.removeByUserId("griddy", "1"), true);
            Assert.AreEqual(vac_context.removeByUserId("1"), true);
            Assert.AreEqual(account_context.removeByUserId("griddy"), true);
        }