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_checkUserData() { /*Verify the data to save: * 1: Data is ok to save. * -1: userName is missing. * -2: userName exists in data base * -3: Password lenght is less than 8 characters. * -4: Password and Confirm are differents. */ //Reg ok.---> Before test check that ther insn´t a userName=userNick Users aUser = new Users(1, "Nombre", "Apellido", DateTime.Now, "userNick", "12345678", "12345678", "*****@*****.**"); int res=0; res=aUser.checkUserData(connString); Assert.AreEqual(1,res); //User name missing aUser = aUser.LoadData(1, "Nombre", "Apellido", DateTime.Now, "", "12345678", "12345678", "*****@*****.**"); res=0; res=aUser.checkUserData(connString); Assert.AreEqual(-1,res); //Password is different than confirm, but fails because password lenght less than 8 aUser = aUser.LoadData(1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "userNick", "", "12345678", "*****@*****.**"); res=0; res=aUser.checkUserData(connString); Assert.AreEqual(-3,res); //Password is different than confirm aUser = aUser.LoadData(1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "userNick", "12345678", "", "*****@*****.**"); res=0; res=aUser.checkUserData(connString); Assert.AreEqual(-4,res); //Password lenght less than 8 aUser = aUser.LoadData(1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "userNick", "", "", "*****@*****.**"); res=0; res=aUser.checkUserData(connString); Assert.AreEqual(-3,res); //User exists aUser = aUser.LoadData(1, "Nombre", "Apellido", Convert.ToDateTime("12/04/1982"), "admin", "12345678", "12345678", "*****@*****.**"); res = 0; res = aUser.checkUserData(connString); Assert.AreEqual(-2, res); }
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_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 }