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

            "Testing that the parameter is of type Person"
            .x(() => validatorBase.IsOfType(typeof(Person)).OtherwiseThrowException());

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

            "Testing that the parameter is of type null"
            .x(() => act = () => validatorBase.IsOfType(null).OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentNullException>()
               .WithMessage("Value cannot be null.\r\nParameter name: type"));
        }
コード例 #3
0
        public void TestParameterIsOfTypePersonFailsDueToNullValue(string parameterName, Person parameterValue, ClassValidator <Person> validatorBase, Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter is of type Person"
            .x(() => act = () => validatorBase.IsOfType(typeof(Person)).OtherwiseThrowException());

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