public void UserViewModel_UserNameExists_False() { var user = new UsersViewModel(); string userName = "******"; // Make sure the test user does not exist user.DeleteUser(userName); bool actual = user.UserNameExists(userName); Assert.IsFalse(actual); }
public void UserViewModel_UserNameExists_True() { var user = new UsersViewModel(); string userName = "******"; // Make sure the test user is reset every time test is run user.DeleteUser(userName); user.CreateUser(userName, "testpassword", "*****@*****.**", 0, 0); bool actual = user.UserNameExists(userName); Assert.IsTrue(actual); }
private void TryCreateUser() { try { ActionLogger.Log(GetType().FullName + nameof(TryCreateUser), userRole, $"<Creating_User UserName={UserNameTextBox.Text}, Email={EmailTextBox.Text}, RoleId={RoleTextBox.Text}>"); if (usersViewModel.UserNameExists(UserNameTextBox.Text)) { MessageBox.Show("This username exists already!", "", MessageBoxButton.OK); } else if (usersViewModel.EmailExists(EmailTextBox.Text)) { MessageBox.Show("This email exists already!", "", MessageBoxButton.OK); } else { bool created = usersViewModel.CreateUser(UserNameTextBox.Text, Crypto.ConvertToHash(PasswordTextBox.Text), EmailTextBox.Text, RoleTextBox.SelectedIndex, 0); if (created) { MessageBox.Show("User Created!", "", MessageBoxButton.OK); UserNameTextBox.Text = ""; PasswordTextBox.Text = ""; EmailTextBox.Text = ""; RoleTextBox.SelectedIndex = 0; } else { MessageBox.Show("Error Creating User!", "", MessageBoxButton.OK); } } } catch (Exception ex) { Error.ReportOrLog(ex); } }