示例#1
0
        public void TestParameterLessThanOrEqualToPasses(
            string parameterName,
            DateTime parameterValue,
            DateTime valueToCompare,
            DateTimeValidator validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

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

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
示例#2
0
        public void TestParameterLessThanOrEqualToFails(
            string parameterName,
            DateTime parameterValue,
            DateTime valueToCompare,
            DateTimeValidator validatorBase,
            Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

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

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