Ejemplo 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);
 }
Ejemplo n.º 2
0
        public void TestPasswordValidation()
        {
            var validator = new MyRegExValidations();
            var result    = validator.ValidatePassword("Test1234");

            Assert.IsTrue(result);
            result = validator.ValidatePassword("TeSt123467862");
            Assert.IsTrue(result);
            result = validator.ValidatePassword("TeSt123467862.");
            Assert.IsTrue(result);
            result = validator.ValidatePassword("Ta1");
            Assert.IsFalse(result);
            result = validator.ValidatePassword("asdfASDF");
            Assert.IsFalse(result);
            result = validator.ValidatePassword("123456789a");
            Assert.IsFalse(result);
        }