public void Validate_DoubleNumberRange_Correctly(double value, double lowMargin, double highMargin, bool orEqualTo, bool expected) { //Arrange var validator = new GreaterValidator <double>(lowMargin, orEqualTo, new LesserValidator <double>(highMargin, orEqualTo)); //Act bool valid = validator.IsValid(value); //Assert Assert.Equal(expected, valid); }
public void Validate_NumberRange_Correctly(int value, int lowMargin, int highMargin, bool orEqualTo, bool expected) { //Arrange var validator = new GreaterValidator <int>(lowMargin, orEqualTo, new LesserValidator <int>(highMargin, orEqualTo)); //Act bool valid = validator.IsValid(value); //Assert Assert.Equal(expected, valid); }
public void Validate_RangeWithIComparable_Correctly(int val, int low, int high, bool orEqualTo, bool expected) { // Arrange var lowMargin = new Comparable { I = low }; var value = new Comparable { I = val }; var highMargin = new Comparable { I = high }; var validator = new GreaterValidator <Comparable>(lowMargin, orEqualTo, new LesserValidator <Comparable>(highMargin, orEqualTo)); // Act bool isValid = validator.IsValid(value); // Assert Assert.Equal(expected, isValid); }
/// <summary> /// Validates that <paramref name="value"/> is greater than or equal to a specified margin. /// </summary> /// <param name="value">The value to validate which must be convertible to a double.</param> /// <returns>True if valid, false otherwise.</returns> /// <exception cref="InvalidRuleException">Thrown if value is null or its runtime type is not compatible with a double.</exception> public override bool IsValid(object value) { double d = this.GetFromDoubleCompatible(value); return(_validator.IsValid(d)); }