public void UserDAO_Create_UnsuccessfulCreation (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user record. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); // Set the result to false by default. bool result = false; //Act try { // Create the user. userDAO.Create(userRecord); // Create a duplicated user. userDAO.Create(userRecord); } catch (Exception) { // Catch exception and set the true. result = true; } //Assert // Result should be true. Assert.IsTrue(result); }
public void UserDAO_Create_SuccessfulCreation (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user record. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); //Act // Create the user. userDAO.Create(userRecord); // Read the created user's data. UserObject userObject = (UserObject)userDAO.ReadById(username); // If the created user has correct data, set the result to true. bool correctDataResult = DataEquals(userRecord, userObject); //Assert // The created user should have the correct data. Assert.IsTrue(correctDataResult); }
public void UserDAO_CheckEmailExistence_EmailNonExists(string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user for the test. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); userDAO.Create(userRecord); //Act // Check if the email exists, and set the result accordingly. bool emailExistence = userDAO.CheckEmailExistence("nonExistingEmail"); //Assert // The result should be false. Assert.IsFalse(emailExistence); }
public void UserDAO_ReadById_SuccessfulRead (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user for the test. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); userDAO.Create(userRecord); //Act // Read the user's data. UserObject userObject = (UserObject)userDAO.ReadById(username); // Check if it's correct and set the result accordingly. bool correctDataResult = DataEquals(userRecord, userObject); //Assert // Result should be true. Assert.IsTrue(correctDataResult); }
public void UserDAO_DeleteByIds_SuccessfulDeletion (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user for the test. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); userDAO.Create(userRecord); //Act // Delete the user. userDAO.DeleteByIds(new List <string> { username }); // Check if the user exists and set the result accordingly. bool result = userDAO.CheckUserExistence(username); //Assert // The result should be false. Assert.IsFalse(result); }
public void UserDAO_Update_UnsuccessfulUpdate (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user for the test. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); userDAO.Create(userRecord); // Different username with new data. string newString = "new"; int newNumber = 1; UserRecord updatedUserRecord = new UserRecord(NonExistingUsername, newString, newString, newString, newString, newNumber, newString, newString, newNumber, newString, newNumber, newNumber, newNumber, newNumber, newNumber); // Set the result to false by default. bool result = false; //Act try { // Update the user. userDAO.Update(updatedUserRecord); } catch (ArgumentException) { result = true; } //Assert // The result should be true. Assert.IsTrue(result); }
public void UserDAO_Update_SuccessfulUpdate (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user for the test. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); userDAO.Create(userRecord); // Same username with new data. string newString = "new"; int newNumber = 1; UserRecord updatedUserRecord = new UserRecord(username, newString, newString, newString, newString, newNumber, newString, newString, newNumber, newString, newNumber, newNumber, newNumber, newNumber, newNumber); //Act // Update the user. userDAO.Update(updatedUserRecord); // Read the updated user's data. UserObject userObject = (UserObject)userDAO.ReadById(username); // Check if the data are updatd correctly, and set the result accordingly. bool correctDataResult = DataEquals(updatedUserRecord, userObject); //Assert // The result should be true. Assert.IsTrue(correctDataResult); }
public void UserDAO_DeleteByIds_UnsuccessfulDeletion (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user for the test. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); userDAO.Create(userRecord); // Set the result to false by default. bool result = false; //Act try { // Delete the user. userDAO.DeleteByIds(new List <string> { NonExistingUsername }); } catch (ArgumentException) { result = true; } //Assert // The result should be true. Assert.IsTrue(result); }
public void UserDAO_ReadById_UnsuccessfulRead (string username, string name, string email, string phoneNumber, string password, int disabled, string userType, string salt, long tempTimestamp, string emailCode, long emailCodeTimestamp, int loginFailures, long lastLoginFailTimestamp, int emailCodeFailures, int phoneCodeFailures) { //Arrange UnitTestUserDAO userDAO = new UnitTestUserDAO(); // Create a user for the test. UserRecord userRecord = new UserRecord(username, name, email, phoneNumber, password, disabled, userType, salt, tempTimestamp, emailCode, emailCodeTimestamp, loginFailures, lastLoginFailTimestamp, emailCodeFailures, phoneCodeFailures); userDAO.Create(userRecord); bool result = false; //Act try { // Read the user's data. UserObject userObject = (UserObject)userDAO.ReadById(NonExistingUsername); } catch (ArgumentException) { // Catch exception and set the result true. result = true; } //Assert // Result should be true. Assert.IsTrue(result); }
/// <summary> /// Initiates the object and its dependencies. /// </summary> static UserManagementServiceUT() { _userDAO = new UnitTestUserDAO(); _ipDAO = new UnitTestIPAddressDAO(); }