public void GetValidationResult_TypeInt_Error() { CustomAssert.ThrowsException<CodedArgumentOutOfRangeException>(() => { ParameterValidator validator = new ParameterValidator(); IEnumerable<ParameterValidationResult> results = validator.GetValidationResult(42, ParameterDataType.None, CreateSimpleConstraints(), Constants.MemberName, Constants.DisplayName); }); }
public void GetValidationResult_MemberNull_Error() { CustomAssert.ThrowsException<CodedArgumentNullOrEmptyException>(() => { ParameterValidator validator = new ParameterValidator(); IEnumerable<ParameterValidationResult> results = validator.GetValidationResult(42, ParameterDataType.Int32, CreateSimpleConstraints(), null, null); }); }
public void GetValidationResult_ValueNullNoConstraint_Success() { ParameterValidator validator = new ParameterValidator(); IEnumerable<ParameterValidationResult> results = validator.GetValidationResult(null, ParameterDataType.Int32, null, Constants.MemberName, Constants.DisplayName); Assert.IsTrue(results.GetEnumerator().MoveNext()); }
public void GetValidationResult_Success() { ParameterValidator validator = new ParameterValidator(); IEnumerable<ParameterValidationResult> results = validator.GetValidationResult(42, ParameterDataType.Int32, CreateSimpleConstraints(), Constants.MemberName, Constants.DisplayName); Assert.IsFalse(results.GetEnumerator().MoveNext()); }
public void Validate_Error() { CustomAssert.ThrowsException<ParameterValidationException>(() => { ParameterValidator validator = new ParameterValidator(); validator.Validate(1, ParameterDataType.Int32, CreateSimpleConstraints(), Constants.MemberName, Constants.DisplayName); }); }
public void Validate_Success() { ParameterValidator validator = new ParameterValidator(); validator.Validate(42, ParameterDataType.Int32, CreateSimpleConstraints(), Constants.MemberName, Constants.DisplayName); }
public void IsValid_Success() { ParameterValidator validator = new ParameterValidator(); Assert.IsTrue(validator.IsValid(42, ParameterDataType.Int32, CreateSimpleConstraints(), Constants.MemberName, Constants.DisplayName)); }
public void GetValidationResult_WithEvents_Success() { ParameterValidator validator = new ParameterValidator(); validator.Validating += (sender, e) => { Assert.AreSame(validator, sender); Assert.AreEqual(2, e.Constraints.Count); Assert.AreEqual(Constants.DisplayName, e.DisplayName); Assert.AreEqual(Constants.MemberName, e.MemberName); Assert.AreEqual(1, e.Value); }; validator.ValidationError += (sender, e) => { Assert.AreSame(validator, sender); Assert.AreEqual(2, e.Constraints.Count); Assert.AreEqual(Constants.DisplayName, e.DisplayName); Assert.AreEqual(Constants.MemberName, e.MemberName); Assert.AreEqual(1, e.Value); List<ValidationResult> res = new List<ValidationResult>(e.ValidationResults); Assert.AreEqual(1, res.Count); }; IEnumerable<ParameterValidationResult> results = validator.GetValidationResult(1, ParameterDataType.Int32, CreateSimpleConstraints(), Constants.MemberName, Constants.DisplayName); Assert.IsTrue(results.GetEnumerator().MoveNext()); }