Exemplo n.º 1
0
        // Logs in the user using the given BankLedger by prompting for their username
        // and password until a successful match is found (or the user decides to exit).
        private static void LogIn(Services.BankLedger ledger)
        {
            // initial prompt to log in
            Console.WriteLine();
            Console.WriteLine($"Enter your username (or \"{EXIT_KEYWORD}\" to return to the main menu):");
            var username = Console.ReadLine();

            if (!username.Equals(EXIT_KEYWORD, StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine("Enter your password:"******"Invalid username/password combination, or account does not exist. Please try again.");
                    Console.WriteLine($"If you need to create an account, type \"{EXIT_KEYWORD}\" to return to the main menu.");
                    Console.WriteLine();
                    Console.WriteLine("Enter your username:"******"Enter your password:"******"Returning to main menu...");
                Console.WriteLine();
            }
        }
Exemplo n.º 2
0
 public void TestLogIn_NoAccount()
 {
     Assert.IsFalse(ledger.LogIn("testUsername", "testPassword"));
     Assert.IsNull(ledger.GetCurrentUser());
     Assert.IsFalse(ledger.IsLoggedIn());
 }