public void loginFailTest() { List <User> users = null; QuizardDatabase db = null; Assert.DoesNotThrow(delegate { db = new QuizardDatabase(); db.Open(); if (!File.Exists("quizard.db")) { int x = db.buildDB(); Assert.AreEqual(x, 0); } Console.WriteLine("database created"); users = db.GetAllUsers(); Console.WriteLine("Query successful"); Console.WriteLine("all users count = " + users.Count); }); foreach (User user in users) { Console.WriteLine("User: "******"email: " + user.Email); Console.WriteLine("password: INVALID"); User logUser = db.loginCheck(user.Email, "INVALID"); Console.WriteLine("query successful"); Assert.IsNull(logUser); Console.WriteLine("--------Login Failed as expected!----------"); } }
private void button1_Click(object sender, EventArgs e) { QuizardDatabase validate = new QuizardDatabase(); User check = validate.loginCheck(userName, password); if (check != null) { LoginSuccessful?.Invoke(check); } else { System.Windows.Forms.MessageBox.Show("User name - " + userName + " does not match password " + password); } //TODO add login action }