public void With_null_value_should_throw() { // Act Action act = () => Iban.Parse(null); // Assert act.Should().Throw <ArgumentNullException>("the provided value was null").Which.ParamName.Should().Be("value"); }
public override void SetUp() { base.SetUp(); _iban = Iban.Parse(TestValues.ValidIban); _equalIban = Iban.Parse(TestValues.ValidIbanPartitioned); _otherIban = Iban.Parse("AE070331234567890123456"); }
public void With_invalid_value_should_throw() { // Act Action act = () => Iban.Parse(TestValues.InvalidIban); // Assert act.ShouldThrow <IbanFormatException>("the provided value was invalid") .Which.Result .Should().Be(IbanValidationResult.IllegalCharacters); }
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_valid_value_should_return_iban() { Iban iban = null; // Act Action act = () => iban = Iban.Parse(TestValues.ValidIban); // Assert act.ShouldNotThrow <IbanFormatException>(); iban.Should().NotBeNull("the value should be parsed") .And.BeOfType <Iban>() .Which.ToString() .Should().Be(TestValues.ValidIban, "the returned value should match the provided value"); }
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."); }
public override void SetUp() { base.SetUp(); _iban = Iban.Parse(TestValues.ValidIban); }