コード例 #1
0
        public void TestParameterEqualToPasses(
            string parameterName,
            sbyte?parameterValue,
            sbyte?valueToCompare,
            NullableNumericValidator <sbyte> 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.IsEqualTo(valueToCompare).OtherwiseThrowException());

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
コード例 #2
0
        public void TestParameterEqualToFails(
            string parameterName,
            sbyte?parameterValue,
            sbyte?valueToCompare,
            NullableNumericValidator <sbyte> 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.IsEqualTo(valueToCompare).OtherwiseThrowException());

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