public void TestParameterLessThanPasses(
            string parameterName,
            byte?parameterValue,
            byte?valueToCompare,
            NullableUnsignedNumericValidator <byte> validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter value is less than the value to compare against"
            .x(() => validatorBase.IsLessThan(valueToCompare).OtherwiseThrowException());

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
        public void TestParameterNotEqualToPasses(
            string parameterName,
            char?parameterValue,
            char?valueToCompare,
            NullableUnsignedNumericValidator <char> validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

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

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
        public void TestParameterConditionOrPasses(
            string parameterName,
            char?parameterValue,
            char?lowerBound,
            char?upperBound,
            NullableUnsignedNumericValidator <char> validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

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

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
        public void TestParameterNotEqualToFails(
            string parameterName,
            char?parameterValue,
            char?valueToCompare,
            NullableUnsignedNumericValidator <char> validatorBase,
            Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

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

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentEqualityException>()
               .WithMessage(string.Format(Resources.MustNotBeEqualToX + "\r\nParameter name: {1}", valueToCompare, parameterName)));
        }
        public void TestParameterLessThanFails(
            string parameterName,
            byte?parameterValue,
            byte?valueToCompare,
            NullableUnsignedNumericValidator <byte> validatorBase,
            Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter value is less than the value to compare against"
            .x(() => act = () => validatorBase.IsLessThan(valueToCompare).OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentOutOfRangeException>()
               .WithMessage(string.Format(Resources.MustBeLessThanX + "\r\nParameter name: {1}", valueToCompare, parameterName)));
        }
        public void TestParameterConditionAndFailsLower(
            string parameterName,
            char?parameterValue,
            char?lowerBound,
            char?upperBound,
            NullableUnsignedNumericValidator <char> 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)));
        }
Пример #7
0
 public static NullableUnsignedNumericValidator <char> That(string nameOfParameter, char?parameterValue)
 {
     return(NullableUnsignedNumericValidator <char> .GetInstance(nameOfParameter, parameterValue));
 }
        public void TestParameterIsPositivePasses(string parameterName, char?parameterValue, NullableUnsignedNumericValidator <char> validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter is false"
            .x(() => validatorBase.IsPositive().OtherwiseThrowException());

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
        public void TestParameterIsPositiveFails(string parameterName, char?parameterValue, NullableUnsignedNumericValidator <char> validatorBase, Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter is false"
            .x(() => act = () => validatorBase.IsPositive().OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentOutOfRangeException>()
               .WithMessage(string.Format(Resources.MustBePositive + "\r\nParameter name: {0}", parameterName)));
        }
        public void TestParameterIsNullFails(string parameterName, byte?parameterValue, NullableUnsignedNumericValidator <byte> validatorBase, Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter is null"
            .x(() => act = () => validatorBase.IsNull().OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentException>()
               .WithMessage(string.Format(Resources.MustBeNull + "\r\nParameter name: {0}", parameterName)));
        }
        public void TestParameterNotNullPasses(string parameterName, byte?parameterValue, NullableUnsignedNumericValidator <byte> validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter is not null"
            .x(() => validatorBase.IsNotNull().OtherwiseThrowException());

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }