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

            try {
                CustomerValidation.ValidateCarType(textBox.Text);
                ResetLabelContent(CarTypeErrLabel);
            } catch (InvalidCarTypeException ex) {
                ShowErrorMessage(CarTypeErrLabel, ex.Message);
            }
        }
Ejemplo n.º 2
0
 public void ValidateCarTypeTestExpectedTrue()
 {
     Assert.IsTrue(CustomerValidation.ValidateCarType("Fiesta S5"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Mondeo"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Falcon"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Mustang"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("EcoSport"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Escape"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Everest"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Escape 5"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Everest 44"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Esc 5"));
     Assert.IsTrue(CustomerValidation.ValidateCarType("Ev 14"));
 }
Ejemplo n.º 3
0
 public void ValidateCarTypeTestInvalidCarTypeException()
 {
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType(""));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType(" "));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("SDD1111%"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("111A--AA"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("SDA!!D111"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType(" SS                         A32 "));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType(" Ty..pe 2 "));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("Bog 4*8 48"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("_wse_()we_we"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("_wse_we_we.9"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("_wse7we._we"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("we?"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("|w|"));
     Assert.ThrowsException <InvalidCarTypeException>(() => CustomerValidation.ValidateCarType("asd@@as"));
 }
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);
 }