コード例 #1
0
        public void TestParameterGreaterThanOrEqualToPasses(
            string parameterName,
            sbyte?parameterValue,
            sbyte?valueToCompare,
            NullableNumericValidator <sbyte> validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter value is greater than or equal to the value to compare against"
            .x(() => validatorBase.IsGreaterThanOrEqualTo(valueToCompare).OtherwiseThrowException());

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
コード例 #2
0
        public void TestParameterConditionAndPasses(
            string parameterName,
            sbyte?parameterValue,
            sbyte?lowerBound,
            sbyte?upperBound,
            NullableNumericValidator <sbyte> validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter value is greater or equal to the lower bound and less than or equal to the upper bound"
            .x(() => validatorBase.IsGreaterThanOrEqualTo(lowerBound).And.IsLessThanOrEqualTo(upperBound).OtherwiseThrowException());

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
コード例 #3
0
        public void TestParameterGreaterThanOrEqualToFails(
            string parameterName,
            sbyte?parameterValue,
            sbyte?valueToCompare,
            NullableNumericValidator <sbyte> validatorBase,
            Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter value is greater than or equal to the value to compare against"
            .x(() => act = () => validatorBase.IsGreaterThanOrEqualTo(valueToCompare).OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentOutOfRangeException>()
               .WithMessage(string.Format(Resources.MustBeGreaterThanOrEqualToX + "\r\nParameter name: {1}", valueToCompare, parameterName)));
        }
コード例 #4
0
        public void TestParameterConditionAndFailsLower(
            string parameterName,
            sbyte?parameterValue,
            sbyte?lowerBound,
            sbyte?upperBound,
            NullableNumericValidator <sbyte> validatorBase,
            Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter value is greater or equal to the lower bound and less than or equal to the upper bound"
            .x(() => act = () => validatorBase.IsGreaterThanOrEqualTo(lowerBound).And.IsLessThanOrEqualTo(upperBound).OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentOutOfRangeException>()
               .WithMessage(string.Format(Resources.MustBeGreaterThanOrEqualToX + "\r\nParameter name: {1}", lowerBound, parameterName)));
        }