public void UserLoginTest() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); User loggedUser = new User(); loggedUser.Username = "******"; loggedUser.Password = "******"; //Test correct password entry Assert.AreEqual(true, repo.TryLogin(loggedUser.Username, loggedUser.Password)); //Test incorrect password entry Assert.AreEqual(false, repo.TryLogin(loggedUser.Username, "Randompass")); }
public ActionResult Login(string naam, string pass) { RPGRepository rpgrepo = new RPGRepository(rpgsql); try { if (rpgrepo.TryLogin(naam, pass)) { userview.LoginMessage = "U bent ingelogd."; userview.UserID = rpgrepo.GetUserId(naam, pass); Session["UserID"] = userview.UserID; userview.Name = naam; userview.Password = pass; userview.Loggedin = true; } else { userview.LoginMessage = "Verkeerde gebruikersnaam of wachtwoord. Probeer het opnieuw."; } } catch (Exception e) { userview.LoginMessage = "Connection to database failed. Please connect to VPN."; } return(View(userview)); }
public void Account_Add() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); string testlogin = "******"; string testPassword = "******"; //Add user with a test login/password repo.AddUserToDB(testlogin, testPassword); //Create a user with the created account User loggedUser = new User(); loggedUser.Username = testlogin; loggedUser.Password = testPassword; //Test correct password entry with the newly created account Assert.AreEqual(true, repo.TryLogin(loggedUser.Username, loggedUser.Password)); //Test incorrect password entry Assert.AreEqual(false, repo.TryLogin(loggedUser.Username, "Randompass")); }