private void loginEvent() { try { user = function.Login(textBoxUserID.Text, textBoxPassword.Text); } catch (Exception e) { MessageBox.Show(e.Message, e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } if (user == null) { MessageBox.Show("Null value, tolong cek koneksi, apakah database sudah dihidupkan apa tidak", "Unknown Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { switch ((int)user.Status) { case 0: MessageBox.Show("Tidak dapat menemukan User, Tolong periksa Username and Password", "Tidak dapat menemukan user", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxPassword.Text = null; break; case 1: GlobalVar.GlobalVarUserID = user.UserID; GlobalVar.GlobalVarPassword = user.Password; GlobalVar.GlobalVarProfileID = user.ProfileID; GlobalVar.GlobalVarUsername = user.Username; textBoxUserID.Text = ""; textBoxPassword.Text = ""; textBoxUserID.Focus(); this.Hide(); TestMenu mainMenuForm = new TestMenu(); mainMenuForm.ShowDialog(); this.Close(); break; case 2: MessageBox.Show("User dalam keadaan Frozen, tolong hubungi admin", "User dalam keadaan frozen", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case 3: MessageBox.Show("User sudah di delete, Tolong pakai user yang lain", "User sudah di delete", MessageBoxButtons.OK, MessageBoxIcon.Error); break; default: MessageBox.Show("Tolong hubungi Admin", "Unknown error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } }
public void Login_Return_Success() { user = function.Login("admin", "adm123"); StringAssert.AreEqualIgnoringCase("admin", user.Username); }