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