Exemplo n.º 1
0
        public void TestAuthenticateEmployeeValid()
        {
            //Arange
            string   username = "******";
            string   password = "******";
            Employee temp;

            //Act
            temp = _employeeManager.AuthenticateEmployee(username, password);
            //Assert
            Assert.AreEqual(temp.FirstName, "Harry");
        }
        /// <summary>
        /// Author: Matt LaMarche
        /// Created : 2/27/2019
        /// Attempts to log in and retrieve an Employee from our database
        ///
        /// Author: Matt LaMarche
        /// Updated Date: 3/7/19
        /// Switched from UserManager to an IEmployeeManager implementation
        /// </summary>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string username = txtUsername.Text;
                string password = pwdPassword.Password;

                if (username.Length < 7 || username.Length > 250)
                {
                    txtUsername.Focus();
                    throw new ArgumentException("Bad Username");
                }
                if (password.Length < 6)
                {
                    pwdPassword.Focus();
                    throw new ArgumentException("Bad Password");
                }

                _employee = _employeeManager.AuthenticateEmployee(username, password);
                if (_employee != null)
                {
                    var devLauncher = new DevLauncher(_employee);
                    this.Close();
                    devLauncher.ShowDialog();
                    _employee = null;
                }
                else
                {
                    throw new ArgumentException("Authentication Failed");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid login attempt: " + ex.Message);
            }
        }