public void TestUrlValidation() { var validator = new MyRegExValidations(); var result = validator.ValidateUrl("www.google.com"); Assert.IsTrue(result); result = validator.ValidateUrl("http://www.google.com"); Assert.IsTrue(result); result = validator.ValidateUrl("https://www.google.com"); Assert.IsTrue(result); result = validator.ValidateUrl("google.com"); Assert.IsTrue(result); result = validator.ValidateUrl("https://policies.google.com"); Assert.IsTrue(result); result = validator.ValidateUrl("https://policies.google.com/technologies/voice?hl=de&gl=ch"); Assert.IsTrue(result); result = validator.ValidateUrl("https://www.policies.google.com/technologies/voice?hl=de&gl=ch"); Assert.IsTrue(result); result = validator.ValidateUrl("ftp://www.policies.google.com/technologies/voice?hl=de&gl=ch"); Assert.IsFalse(result); result = validator.ValidateUrl("asdf"); Assert.IsFalse(result); }
private bool ValidateCustomer() { if (!_regExValidation.ValidateCustomerNo(SelectedItem.CustomerNumber)) { MessageBox.Show("Invalid customer number. It must start with CU following 5 numbers"); return(false); } if (!_regExValidation.ValidateEMail(SelectedItem.Mail)) { MessageBox.Show(@"Invalid mail address."); return(false); } if (!_regExValidation.ValidateUrl(SelectedItem.Website)) { MessageBox.Show(@"Invalid url."); return(false); } if (!_regExValidation.ValidatePassword(SelectedItem.Password)) { MessageBox.Show(@"Invalid invalid password."); return(false); } if (string.IsNullOrWhiteSpace(SelectedItem.Name)) { MessageBox.Show(@"Name is required."); return(false); } if (SelectedItem.Address == null) { MessageBox.Show(@"Select an address."); return(false); } if (SelectedItem.AddressType == null) { MessageBox.Show(@"Select an address type."); return(false); } return(true); }