[InlineData("C", "twobigavalue", false)] //password too big public void ValidateUserInput_stringsShouldVerify(string username, string password, bool expected) { //Arrange LoginProcess loginProcess = new LoginProcess(); //Act bool actual = loginProcess.ValidateLoginData(username, password); //assert Assert.Equal(expected, actual); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { bool validated; //obtain user details for passing in to the Dashboard screen string currentUser = tbxUsername.Text.Trim(); string currentPassword = tbxPassword.Password.Trim(); if (activeTab == "Logon") { validated = loginProcess.ValidateLoginData(currentUser, currentPassword); if (validated == true) { // For existing logged on user var query = (from u in db.Users join m in db.Members on u.airc_id equals m.airc_id where u.username == currentUser && u.userpassword == currentPassword select new { m.role, u.username, u.userpassword, u.airc_id, m.club_id }); foreach (var record in query) { MainDashboard maindashboard = new MainDashboard(); this.Hide(); close = true; // set variables needed for the maindashboard. Mainly used for showing next avilable competition. maindashboard.currentPassword = currentPassword; maindashboard.tbxUsername.Text = record.username; maindashboard.airc_id = record.airc_id; maindashboard.member_role = record.role; maindashboard.club_id = record.club_id; maindashboard.ShowDialog(); } this.Close(); // By Default if we reach here that means we have an invalid username and/or password entered if (close == false) { MessageBox.Show($"Incorrect username or Password"); } // We need to ensure that application is executed gracefully else { if (close == false) { MessageBox.Show("Username or password not entered or too big"); } } } } else if (activeTab == "Register") { airc_id = Convert.ToInt16(tbxAIRC_ID.Text.Trim()); validated = registerProcess.ValidateRegistrationData(currentUser, currentPassword, airc_id, tbxFirstname.Text.Trim(), tbxLastName.Text.Trim(), club_id, DRgrade, SJgrade, XCgrade, tbxPhone.Text, tbxEmail.Text); string role = "M"; //Role is Member string memberStatus = "N"; //Member status is "N" for new Membe // call Register user Method RegisterUser( airc_id, currentUser, currentPassword); // As user does not get id generated from an identity column, we are forced to save userdetails here. // ideally we should use a db sequence value. SaveRegistration(); //RegisterMember Method. We should really have just passed in the mmeber Class. Will do so if time permits. RegisterMember( airc_id, club_id, memberStatus, role, tbxFirstname.Text.Trim(), tbxLastName.Text.Trim(), DRgrade.Trim(), SJgrade.Trim(), XCgrade.Trim(), tbxPhone.Text, tbxEmail.Text); // Here we save the registration. SaveRegistration(); //We force self registered users to log on with their new username and password. MessageBox.Show($"Your user {currentUser} has been saved. Please login again with your username and password"); this.Close(); } }