Exemplo n.º 1
0
        public void TestParameterImplementsInterfacePasses(string parameterName, Person parameterValue, ClassValidator <Person> validatorBase, Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter implements interface IOfficer"
            .x(() => validatorBase.ImplementsInterface(typeof(IOfficer)).OtherwiseThrowException());

            "Should not result in an exception"
            .x(() => validatorBase.CurrentException.Should().BeNull());
        }
Exemplo n.º 2
0
        public void TestParameterImplementsInterfaceFailsDueToNonInterface(string parameterName, Person parameterValue, ClassValidator <Person> validatorBase, Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter implements interface IOfficer"
            .x(() => act = () => validatorBase.ImplementsInterface(typeof(Officer)).OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentTypeException>()
               .WithMessage(Resources.MustBeInterface + "\r\nParameter name: type"));
        }
Exemplo n.º 3
0
        public void TestParameterImplementsInterfaceFailsDueToNullType(string parameterName, Person parameterValue, ClassValidator <Person> validatorBase, Action act)
        {
            "Given a new ValidatorBase"
            .x(() => validatorBase = Validate.That(parameterName, parameterValue));

            "Testing that the parameter implements interface IOfficer"
            .x(() => act = () => validatorBase.ImplementsInterface(null).OtherwiseThrowException());

            "Should throw an exception"
            .x(() => act.ShouldThrow <ArgumentNullException>()
               .WithMessage("Value cannot be null.\r\nParameter name: type"));
        }