public void CheckEmail() { InputValidatorMain.InputValidator iv = new InputValidatorMain.InputValidator(); string email; email = "*****@*****.**"; Assert.IsTrue(iv.ValidateEmail(email)); email = "*****@*****.**"; Assert.IsTrue(iv.ValidateEmail(email)); email = "*****@*****.**"; Assert.IsTrue(iv.ValidateEmail(email)); email = "[email protected]_"; Assert.IsFalse(iv.ValidateEmail(email)); email = "local@domain."; Assert.IsFalse(iv.ValidateEmail(email)); email = "local@domain"; Assert.IsFalse(iv.ValidateEmail(email)); email = "@domain.hu"; Assert.IsFalse(iv.ValidateEmail(email)); email = "local.hu"; Assert.IsFalse(iv.ValidateEmail(email)); email = "localdomainhu"; Assert.IsFalse(iv.ValidateEmail(email)); }
private void SaveButton_Click(object sender, EventArgs e) { InputValidator iv = new InputValidator(); if (!iv.ValidateName(nameTextBox.Text)) { MessageBox.Show("The name is invalid (only alphabetical characters are allowed)"); } try { phoneTextBox.Text = iv.ReformatPhone(phoneTextBox.Text); } catch (ArgumentException) { MessageBox.Show("The phone number is not valid."); } if (!iv.ValidateEmail(emailTextBox.Text)) { MessageBox.Show("The e-mail address is not valid."); } }