public void Users_loginTest() { //Creates an User with data. Users aUser = new Users(-1, "name", "", DateTime.Now, "", "", "", ""); //Try to save first aUser = aUser.LoadData(-1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "NickToDel", "12345678", "12345678", "*****@*****.**"); aUser = aUser.saveUserData(connString); Assert.AreNotEqual(-1, aUser.userID); //1=save data without any problem. //Try to find it and take the userID //findUserByUserName returns a user if find, if not find return a user wit UserID=-1 string expectedUserName = aUser.userName; Int64 userIDToDelete = aUser.userID; aUser = aUser.findUserByUserName(connString, expectedUserName); Assert.AreEqual(expectedUserName, aUser.userName); Int64 expectedUserID = aUser.userID; //Correct login string givenPassword = "******"; aUser = aUser.verifyPass(aUser.userName, givenPassword, connString); Assert.AreNotEqual(-1, aUser.userID); //Uncorrect Login givenPassword = ""; aUser = aUser.verifyPass(aUser.userName, givenPassword, connString); Assert.AreEqual(-1, aUser.userID); //Try to Delete previous saved user. int res = Users.deleteUserByUserID(connString, userIDToDelete); Assert.AreEqual(1, res); //Deleted with success }
public void Users_UpdateTestWithPass() { //Creates an User with data. Users aUser = new Users(-1, "name", "", DateTime.Now, "", "", "", ""); //Try to save first aUser = aUser.LoadData(-1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "NickToDel", "12345678", "12345678", "*****@*****.**"); aUser = aUser.saveUserData(connString); Assert.AreNotEqual(-1, aUser.userID); //1=save data without any problem. //Try to find it and take the userID //findUserByUserName returns a user if find, if not find return a user wit UserID=-1 string expectedUserName = aUser.userName; aUser = aUser.findUserByUserName(connString, expectedUserName); Assert.AreEqual(expectedUserName, aUser.userName); //User finded Int64 expectedUserID = aUser.userID; //Try to Update previous saved user. string newPass="******"; aUser.userPass = newPass; aUser.userConfirmPassword = newPass; aUser = aUser.updateUserData(connString, true); aUser = aUser.verifyPass(aUser.userName, newPass, connString); Assert.AreNotEqual(-1, aUser.userID); //Verify if new password was stored correctly //Try to Delete previous saved user. Int64 res = Users.deleteUserByUserID(connString, aUser.userID); Assert.AreEqual(1, res); //Deleted with success ////Try to find it ////findUserByUserName returns a user if find, if not find return a user wit UserID=-1 //expectedUserName = aUser.userName; //aUser = aUser.findUserByUserName(connString, expectedUserName); //Assert.AreEqual(-1, aUser.userID); //user not found because was deleted }
public void Users_TestSaveUser() { //Creates anUser with data. Users aUser = new Users(-1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "userNick", "12345678", "12345678", "*****@*****.**"); aUser = aUser.saveUserData(connString); Assert.AreNotEqual(-1, aUser.userID); //1=save data without any problem. }
public void Users_UpdateTestWithoutPass() { //Creates an User with data. Users aUser = new Users(-1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "NickToDel", "12345678", "12345678", "*****@*****.**"); //Try to save first aUser = aUser.saveUserData(connString); Assert.AreNotEqual(-1, aUser.userID); //1=save data without any problem. //Try to find it and take the userID //findUserByUserName returns a user if find, if not find return a user wit UserID=-1 Users aUserToFind = aUser.findUserByUserName(connString, aUser.userName); Assert.AreEqual(aUser.userName, aUserToFind.userName); Int64 expectedUserID = aUser.userID; //Try to Update previous saved user. aUser.userSecondName = "Second Name Updated"; aUser = aUser.updateUserData(connString,false); Assert.AreNotEqual(-1, aUser.userID); //1=update data without any problem. //Try to find it //findUserByUserName returns a user if find, if not find return a user wit UserID=-1 aUserToFind = aUser.findUserByUserID(connString,aUser.userID); Assert.AreEqual(aUser.userName, aUserToFind.userName); //Verify the update. Assert.AreEqual(aUser.userSecondName,aUserToFind.userSecondName); //Try to Delete previous saved user. int res = Users.deleteUserByUserID(connString, aUser.userID); Assert.AreEqual(1, res); //Deleted with success //Try to find it aUser = aUser.findUserByUserID(connString, aUser.userID); Assert.AreEqual(-1, aUser.userID); //user not found because was deleted }
public void Users_TestDeleteUserName() { //Creates an User with data. Users aUser = new Users(-1, "name", "", DateTime.Now, "", "", "", ""); //Try to save first aUser = aUser.LoadData(-1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "NickToDel", "12345678", "12345678", "*****@*****.**"); aUser = aUser.saveUserData(connString); Assert.AreNotEqual(-1, aUser.userID); //1=save data without any problem. //Try to find it //findUserByUserName returns a user if find, if not find return a user wit UserID=-1 string expectedUserName = aUser.userName; aUser = aUser.findUserByUserName(connString, expectedUserName); Assert.AreNotEqual(-1, aUser.userID); //User finded //Try to Delete previous saved user. int res = Users.deleteUserByUserID(connString, aUser.userID); Assert.AreEqual( 1, res); //Deleted with success //Try to find it //findUserByUserName returns a user if find, if not find return a user wit UserID=-1 aUser = aUser.findUserByUserName(connString, expectedUserName); Assert.AreEqual(-1, aUser.userID); //User not found because was deleted }