Ejemplo n.º 1
0
        private void LicensePlateTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textBox = sender as TextBox;

            try {
                CustomerValidation.ValidateLicensePlateName(textBox.Text);
                ResetLabelContent(LicensePlateErrLabel);
            } catch (InvalidLicensePlateException ex) {
                ShowErrorMessage(LicensePlateErrLabel, ex.Message);
            }
        }
Ejemplo n.º 2
0
 public void ValidateLicensePlateNameTestThrowInvalidLicensePlateException()
 {
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName(""));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName(" "));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("SDD1111"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("1111AAA"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("SDAD111"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("SSA1132"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("11111"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("SSSSS"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("SD11AS11"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("SSA1132"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("1"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("SSSSSDFS"));
     Assert.ThrowsException <InvalidLicensePlateException>(() => CustomerValidation.ValidateLicensePlateName("!+%+"));
 }
Ejemplo n.º 3
0
 public void ValidateLicensePlateNameTestExpectedTrue()
 {
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("WWW111"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("KLK231"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("QWE231"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("FRD231"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("SDD123"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("SDW123"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("SDC431"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("WUW111"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("ULK231"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("QWU231"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("FRF231"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("SSD123"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("SWW123"));
     Assert.IsTrue(CustomerValidation.ValidateLicensePlateName("SDE431"));
 }
Ejemplo n.º 4
0
 private bool ValidateInput()
 {
     try {
         CustomerValidation.ValidateFirstName(FirstNameTextBox.Text);
         CustomerValidation.ValidateLastName(LastNameTextBox.Text);
         CustomerValidation.ValidateBrandName(CarBrandTextBox.Text);
         CustomerValidation.ValidateCarType(CarTypeTextBox.Text);
         CustomerValidation.ValidateLicensePlateName(LicensePlateTextBox.Text);
         return(true);
     } catch (InvalidFirstNameException e) {
         ShowErrorMessage(FirstNameErrLabel, e.Message);
     } catch (InvalidLastNameException e) {
         ShowErrorMessage(LastNameErrLabel, e.Message);
     } catch (InvalidBrandNameException e) {
         ShowErrorMessage(CarBrandErrLabel, e.Message);
     } catch (InvalidCarTypeException e) {
         ShowErrorMessage(CarTypeErrLabel, e.Message);
     } catch (InvalidLicensePlateException e) {
         ShowErrorMessage(LicensePlateErrLabel, e.Message);
     }
     return(false);
 }