public static User Login() { using IPizzaboxRepository pizzaboxRepository = DbOptions.CreatePizzaboxRepository(); User Me = new User(); trials = 3; do { #region Username and Password Entry Console.WriteLine("USER LOGIN"); Console.Write("Username: "******"Password: "******"authentication"); continue; } #endregion #region Authentication Me = AuthorizedUser; bool success = false; switch (Me.SessionLive) { //ALREADY LOGGED IN case 1: /* * Error("session"); * break; */ //NOT LOGGED IN case 0: Console.WriteLine("Login successful\n"); Me.SessionLive = 1; pizzaboxRepository.UpdateUser(Me); success = true; break; } if (success) { break; } #endregion } while (trials > 0); return(Me); }
public void Fail_Authentication() { // ARRANGE using IPizzaboxRepository pizzaboxRepository = DbOptions.CreatePizzaboxRepository(); User Expected = null; string[] username_auth = { "admin", "Uname23", "Admin", "uname23", "ad", "Uname", "Password123", "adminpass" }; string[] password_auth = { "adminpas", "Password", "adminpass", "Password123", "admin", "password123", "Uname23", "admin" }; for (int i = 0; i < username_auth.Length; i++) { // ACT User Actual = pizzaboxRepository.UserAuthentication(username_auth[i], password_auth[i]); // ASSERT Assert.Equal(Expected, Actual); } }