Exemple #1
0
        public void TestCustomerNumberValidation()
        {
            var validator = new MyRegExValidations();
            var result    = validator.ValidateCustomerNo("CU12345");

            Assert.IsTrue(result);
            result = validator.ValidateCustomerNo("CU123456");
            Assert.IsFalse(result);
            result = validator.ValidateCustomerNo("KU12345");
            Assert.IsFalse(result);
            result = validator.ValidateCustomerNo("");
            Assert.IsFalse(result);
            result = validator.ValidateCustomerNo(null);
            Assert.IsFalse(result);
        }
Exemple #2
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);
 }