public void ParameterMaxValueTest_ValidationPassTest() { bool isValid; string[] args; // // MAX VALUES // 100, 101, 102, 103, 104, 105, 106.5, 107.5, 108.5, 109.5, 110.5, 111.5 // ParameterMaxValue parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsTrue(isValid, "The validation of 'ParameterMaxValue' should pass."); }
public void ParameterMaxValueTest_ValidationFailTest() { ParameterMaxValue parameterMaxValue; ValidationError validationError; bool isValid; string[] args; // // MAX VALUES // 100, 101, 102, 103, 104, 105, 106.5, 107.5, 108.5, 109.5, 110.5, 111.5 // parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=101", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=102", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullInt16").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullInt16'."); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=103", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=104", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=105", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=106", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullInt64").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullInt64'."); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.7", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.7", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullSingle").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullSingle'."); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.6", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.53", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.57", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.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=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.59" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullDecimal").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullDecimal'."); // // NULL TEST // parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=100", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullInt16").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullInt16'."); parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestInt64=104", "TestNullInt64=105", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullInt").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullInt'."); parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullInt64").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullInt64'."); parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestInt64=104", "TestSingle=106.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullSingle").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullSingle'."); parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestInt64=104", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5" , "TestDecimal=110.5", "TestNullDecimal=111.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullDouble").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullDouble'."); parameterMaxValue = new ParameterMaxValue("ParameterMaxValueTest", Assembly.GetExecutingAssembly()); args = new string[] { "TestInt16=100", "TestNullInt16=101", "TestInt=102", "TestNullInt=103", "TestInt64=104", "TestInt64=104", "TestSingle=106.5", "TestNullSingle=107.5", "TestDouble=108.5", "TestNullDouble=109.5", "TestDecimal=110.5" }; parameterMaxValue.Parse(args); isValid = parameterMaxValue.Validate(); Assert.IsFalse(isValid, "The validation of 'parameterMaxValueTest' should fail for an invalid value."); validationError = parameterMaxValue.ValidationErrorList.Where(err => err.PropertyMetaInfo.PropertyInfo.Name == "TestNullDecimal").SingleOrDefault(); Assert.IsNotNull(validationError, "The validation should fail for the invalid value on 'TestNullDecimal'."); }