コード例 #1
0
ファイル: IbanTests.cs プロジェクト: skwasjer/IbanNet
            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");
            }
コード例 #2
0
            public override void SetUp()
            {
                base.SetUp();

                _iban      = Iban.Parse(TestValues.ValidIban);
                _equalIban = Iban.Parse(TestValues.ValidIbanPartitioned);
                _otherIban = Iban.Parse("AE070331234567890123456");
            }
コード例 #3
0
ファイル: IbanTests.cs プロジェクト: meghuizen/IbanNet
            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);
            }
コード例 #4
0
ファイル: IbanTests.cs プロジェクト: skwasjer/IbanNet
            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.");
            }
コード例 #5
0
ファイル: IbanTests.cs プロジェクト: meghuizen/IbanNet
            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");
            }
コード例 #6
0
ファイル: IbanTests.cs プロジェクト: skwasjer/IbanNet
            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");
            }
コード例 #7
0
ファイル: IbanTests.cs プロジェクト: skwasjer/IbanNet
            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.");
            }
コード例 #8
0
            public override void SetUp()
            {
                base.SetUp();

                _iban = Iban.Parse(TestValues.ValidIban);
            }