public void TestParameterEqualToWithCustomExceptionPasses(string parameterName, bool parameterValue, bool valueToCompare, BooleanValidator 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 and throwing a custom exception if not" .x(() => validatorBase.IsEqualTo(valueToCompare).OtherwiseThrow(new ArgumentException("Some nonsense message", parameterName))); "Should not result in an exception" .x(() => validatorBase.CurrentException.Should().BeNull()); }
public void TestParameterEqualToPasses(string parameterName, bool parameterValue, bool valueToCompare, BooleanValidator 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()); }
public void TestParameterEqualToWithCustomExceptionFails(string parameterName, bool parameterValue, bool valueToCompare, BooleanValidator 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 and throwing a custom exception if not" .x(() => act = () => validatorBase.IsEqualTo(valueToCompare).OtherwiseThrow(new ArgumentException("Some nonsense message", parameterName))); "Should result in that custom exception being thrown" .x(() => act.ShouldThrow <ArgumentException>() .WithMessage(string.Format("Some nonsense message\r\nParameter name: {0}", parameterName))); }
public void TestParameterEqualToFails(string parameterName, bool parameterValue, bool valueToCompare, BooleanValidator 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))); }