public void With_value_that_causes_custom_rule_to_throw_should_rethrow() { // Act Action act = () => Iban.Parse(TestValues.IbanForCustomRuleException); // Assert IbanFormatException ex = act.Should().Throw <IbanFormatException>("the provided value was invalid").Which; ex.Result.Should().BeNull(); ex.InnerException.Should().NotBeNull(); ex.Message.Should().Contain("is not a valid IBAN."); }
public void With_value_that_fails_custom_rule_should_throw() { // Act Action act = () => Iban.Parse(TestValues.IbanForCustomRuleFailure); // Assert IbanFormatException ex = act.Should().Throw <IbanFormatException>("the provided value was invalid").Which; ex.Result.Should().BeEquivalentTo(new ValidationResult { Error = new ErrorResult("Custom message"), AttemptedValue = TestValues.IbanForCustomRuleFailure }); ex.InnerException.Should().BeNull(); ex.Message.Should().Be("Custom message"); }
public void With_invalid_value_should_throw() { // Act Action act = () => Iban.Parse(TestValues.InvalidIban); // Assert IbanFormatException ex = act.Should().Throw <IbanFormatException>("the provided value was invalid").Which; ex.Result.Should().BeEquivalentTo(new ValidationResult { Error = new IllegalCharactersResult(), AttemptedValue = TestValues.InvalidIban }); ex.InnerException.Should().BeNull(); ex.Message.Should().Be("The IBAN contains illegal characters."); }