Exemplo n.º 1
0
    public void ParameterMinValueTest_ValidationPassTest()
    {
      bool isValid;
      string[] args;
      
      //
      // MIN VALUES
      // 40, 41, 42, 43, 44.4, 45, 46.6, 47.7, 50.1, 51
      //

      ParameterMinValue parameterMinValue = new ParameterMinValue("ParameterMinValueTest", Assembly.GetExecutingAssembly());
      
      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsTrue(isValid, "The validation of 'parameterMinValue' should pass.");
    }
Exemplo n.º 2
0
    public void ParameterMinValueTest_ValidationFailTest()
    {
      ParameterMinValue parameterMinValue;
      ValidationError validationError;
      bool isValid;
      string[] args;
      
      //
      // MIN VALUES
      // 40, 41, 42, 43, 44.4, 45, 46.6, 47.7, 50.1, 51
      //

      parameterMinValue = new ParameterMinValue("ParameterMinValueTest", Assembly.GetExecutingAssembly());
      
      args = new string[] { "TestInt16=39", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestInt16").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestInt16'.");

      args = new string[] { "TestInt16=40", "TestInt=40", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestInt").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestInt'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=41", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestInt64").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestInt64'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=42", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestDouble").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestDouble'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.3", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestDecimal").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestDecimal'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=44", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullInt").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullInt'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.5", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullDouble").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullDouble'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.6", "TestSingle=50.1", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullDecimal").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullDecimal'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50", "TestNullSingle=51"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestSingle").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestSingle'.");

      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=50.9"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullSingle").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullSingle'.");

      //
      // NULL TEST
      //

      parameterMinValue = new ParameterMinValue("ParameterMinValueTest", Assembly.GetExecutingAssembly());
      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4",                 "TestNullDouble=46.6", "TestNullDecimal=47.7", "TestSingle=50.1", "TestNullSingle=50.9"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullInt").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullInt'.");

      parameterMinValue = new ParameterMinValue("ParameterMinValueTest", Assembly.GetExecutingAssembly());
      args = new string[] { "TestInt16=40", "TestInt=41", "TestInt64=42", "TestDouble=43", "TestDecimal=44.4", "TestNullInt=45", "TestNullDouble=46.6",                         "TestSingle=50.1", "TestNullSingle=50.9"  };
      parameterMinValue.Parse(args);
      isValid = parameterMinValue.Validate();
      Assert.IsFalse(isValid, "The validation of 'parameterMinValue' should fail for an invalid value.");
      validationError = parameterMinValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullDecimal").SingleOrDefault();
      Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullDecimal'.");
    }