コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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)));
        }
コード例 #5
0
        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)));
        }
コード例 #6
0
        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)));
        }
コード例 #7
0
        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)));
        }
コード例 #8
0
        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());
        }
コード例 #9
0
        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)));
        }
コード例 #10
0
ファイル: Validate.cs プロジェクト: wiredwiz/FluentGuard
 public static UnsignedNumericValidator <char> That(string nameOfParameter, char parameterValue)
 {
     return(UnsignedNumericValidator <char> .GetInstance(nameOfParameter, parameterValue));
 }
コード例 #11
0
ファイル: Validate.cs プロジェクト: wiredwiz/FluentGuard
 public static UnsignedNumericValidator <ushort> That(string nameOfParameter, ushort parameterValue)
 {
     return(UnsignedNumericValidator <ushort> .GetInstance(nameOfParameter, parameterValue));
 }