public void CheckPhone() { InputValidatorMain.InputValidator iv = new InputValidatorMain.InputValidator(); string phone; phone = "123-456-7890"; Assert.IsTrue(iv.ValidatePhone(phone)); phone = "362-185-2394"; Assert.IsTrue(iv.ValidatePhone(phone)); phone = "3621852394"; Assert.IsTrue(iv.ValidatePhone(phone)); phone = "(362) 185-2394"; Assert.IsTrue(iv.ValidatePhone(phone)); phone = "(362)185-2394"; Assert.IsTrue(iv.ValidatePhone(phone)); phone = "(362)-185-2394"; Assert.IsTrue(iv.ValidatePhone(phone)); phone = "h362-1865-2394"; Assert.IsFalse(iv.ValidatePhone(phone)); phone = "h362-1865-2394h"; Assert.IsFalse(iv.ValidatePhone(phone)); phone = "362_1865_2394"; Assert.IsFalse(iv.ValidatePhone(phone)); /* */ }
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)); }
public void CheckName() { InputValidatorMain.InputValidator iv = new InputValidatorMain.InputValidator(); string name; name = "kalman"; Assert.IsTrue(iv.ValidateName(name)); name = "4kalman"; Assert.IsFalse(iv.ValidateName(name)); name = "Kalman"; Assert.IsTrue(iv.ValidateName(name)); name = "kal4man"; Assert.IsFalse(iv.ValidateName(name)); name = "kalman4"; Assert.IsFalse(iv.ValidateName(name)); name = "kal4man_"; Assert.IsFalse(iv.ValidateName(name)); name = "kaLmaN"; Assert.IsTrue(iv.ValidateName(name)); name = "kal_man"; Assert.IsFalse(iv.ValidateName(name)); name = "kasza blanka"; Assert.IsFalse(iv.ValidateName(name)); }
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."); } }