Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
        public void TestEMailValidation()
        {
            var validator = new MyRegExValidations();
            var result    = validator.ValidateEMail("*****@*****.**");

            Assert.IsTrue(result);
            result = validator.ValidateEMail("*****@*****.**");
            Assert.IsTrue(result);
            result = validator.ValidateEMail("*****@*****.**");
            Assert.IsTrue(result);
            result = validator.ValidateEMail("*****@*****.**");
            Assert.IsTrue(result);
            result = validator.ValidateEMail("*****@*****.**");
            Assert.IsTrue(result);
            result = validator.ValidateEMail("gabriel-weibel_123@gmail1..");
            Assert.IsFalse(result);
        }