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()); }
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")); }
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")); }