コード例 #1
0
        public void TestParameterEndsWithFailsNull(string parameterName, string parameterValue, string nullValue, StringValidator validatorBase, Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter ends with a null string"
            .x(() => act = () => validatorBase.EndsWith(nullValue).OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentNullException>());
        }
コード例 #2
0
        public void TestParameterEndsWithPasses(string parameterName, string parameterValue, string valueToCompare, StringValidator validatorBase)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter ends with a given string"
            .x(() => validatorBase.EndsWith(valueToCompare).OtherwiseThrowException());

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

            "Testing that the parameter ends with a given string"
            .x(() => act = () => validatorBase.EndsWith(valueToCompare).OtherwiseThrowException());

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