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."); } }