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")); }
protected void Button2_Click(object sender, EventArgs e) { DAO_Account_Interface user_ctx = new AccountDAO(); if (user_ctx.isFound(txtUserName.Text)) { btnValidUser.Enabled = false; btnDelUser.Enabled = true; btnResetPassword.Enabled = true; txtStatus.Text = ""; txtUserName.Enabled = false; if (service.isAccountBlocked(txtUserName.Text)) btnUnblock.Enabled = true; else btnUnblock.Enabled = false; } else { btnValidUser.Enabled = true; btnResetPassword.Enabled = false; btnDelUser.Enabled = false; btnResetPassword.Enabled = false; txtStatus.Text = "Invalid User Name Entered!"; txtUserName.Enabled = true; } }
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"; }
/* * 1 Successfull * 2 Invalid User * 3 E-mail Address not found * 4 Unable to send E-mail - contact administrator * 5 E-mail successfully sent */ public int forgotPassword(string userName,string message) { string newPassword = System.Web.Security.Membership.GeneratePassword(8, 2); int flag = 2;//Invalid user AccountDAO acc_context = new AccountDAO(); ContactInfoDAO con_context = new ContactInfoDAO(); if (acc_context.isFound(userName)) { if (con_context.isFound(userName, "e-mail")) { ContactInfoDTO email = con_context.find(userName, "e-mail"); AccountDTO account = acc_context.find(userName); account.password = newPassword; acc_context.merge(account); message.Replace("PASSWORD", newPassword); flag = sendMail(email.data, message); } else { flag = 3; //Email Address not found } } return flag; }
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); }