public void TestWrongPasswordFailedAuthentication(string username, string badPassword, string expectedMessage, bool expectedSuccess, int expectedAccountId) { _testAccountCreator.ValidateCredentials("testUser", "testPassword", "testPassword"); var testLoginResponse = _testLoginService.AuthenticateCredentials(username, badPassword); Assert.Equal(expectedMessage, testLoginResponse.Message); Assert.Equal(expectedSuccess, testLoginResponse.RequestSuccess); Assert.Equal(expectedAccountId, testLoginResponse.AccountId); }
public void AccountCreationTest(string username, string password1, string password2, bool expectedSuccess, string expectedMessage) { _testAccountCreator.NewAccountId = 1; var response = _testAccountCreator.ValidateCredentials(username, password1, password2); Assert.Equal(expectedMessage, response.Message); Assert.Equal(expectedSuccess, response.RequestSuccess); }
static void Main(string[] args) { //instantiate dependencies of AccountCreatorService and LoginService var encryptionUtility = new EncryptionUtility(); var accountOptions = new DbContextOptionsBuilder <AccountDbContext>() .UseInMemoryDatabase("BankingAppDatabase") .Options; var accountDbContext = new AccountDbContext(accountOptions); var accountQueries = new AccountQueries(accountDbContext); var accountId = 1; while (true) { Console.WriteLine("Welcome to Taylor Bank. Please choose from the following menu options:"); Console.WriteLine("a) Create new account"); Console.WriteLine("b) Login"); Console.WriteLine("c) Quit"); var menuChoice = Console.ReadLine(); switch (menuChoice) { case "a": var accountCreator = new AccountCreator(encryptionUtility, accountQueries); accountCreator.NewAccountId = accountId; var accountCreated = false; var creationAttempts = 0; //used as a flag to limit failed attempts so users don't get stuck in an endless loop while (!accountCreated) { var newUsername = GetUserInput("Username:"******"Password:"******"Re-enter password:"******"Exiting after 5 failed account creation attempts.\n"); break; } accountId++; break; case "b": var loggedIn = false; var loginAttempts = 0; var loggedInAccountId = -1; var loginService = new LoginService(encryptionUtility, accountQueries); while (!loggedIn) { var username = GetUserInput("Username:"******"Password:"******"Exiting after 5 failed login attempts.\n"); break; } //loggedInAccountId always equals -1 unless the account credentials have been successfully validated if (loggedInAccountId != -1) { LoggedInMenuOptions(loggedInAccountId, ref loggedIn); } break; case "c": Quit(); break; default: Console.WriteLine("Invalid selection, please choose again.\n"); break; } } }