public void TestParameterNotEqualToPasses(
            string parameterName,
            uint parameterValue,
            uint valueToCompare,
            UnsignedNumericValidator <uint> 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 TestParameterLessThanPasses(
            string parameterName,
            ulong parameterValue,
            ulong valueToCompare,
            UnsignedNumericValidator <ulong> 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 TestParameterConditionOrPasses(
            string parameterName,
            uint parameterValue,
            uint lowerBound,
            uint upperBound,
            UnsignedNumericValidator <uint> 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,
            uint parameterValue,
            uint valueToCompare,
            UnsignedNumericValidator <uint> 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,
            ulong parameterValue,
            ulong valueToCompare,
            UnsignedNumericValidator <ulong> 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 TestParameterGreaterThanOrEqualToFails(
            string parameterName,
            char parameterValue,
            char valueToCompare,
            UnsignedNumericValidator <char> 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)));
        }
        public void TestParameterConditionAndFailsLower(
            string parameterName,
            uint parameterValue,
            uint lowerBound,
            uint upperBound,
            UnsignedNumericValidator <uint> 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)));
        }
        public void TestParameterIsPositivePasses(string parameterName, uint parameterValue, UnsignedNumericValidator <uint> 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, uint parameterValue, UnsignedNumericValidator <uint> 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)));
        }
Example #10
0
 public static UnsignedNumericValidator <char> That(string nameOfParameter, char parameterValue)
 {
     return(UnsignedNumericValidator <char> .GetInstance(nameOfParameter, parameterValue));
 }
Example #11
0
 public static UnsignedNumericValidator <ushort> That(string nameOfParameter, ushort parameterValue)
 {
     return(UnsignedNumericValidator <ushort> .GetInstance(nameOfParameter, parameterValue));
 }