public void Given_bankAccountNumber_when_building_it_should_return_value(Type builderType, string countryCode, string bankAccountNumber, string expected)
        {
            IBankAccountBuilder builder = CreateBuilder(builderType)
                                          .WithCountry(countryCode, IbanRegistry.Default)
                                          .WithBankAccountNumber(bankAccountNumber);

            // Act
            string actual = builder.Build();

            // Assert
            actual.Should().Be(expected);
        }
        public void Given_only_country_when_building_it_should_not_throw(Type builderType, string countryCode, string expected)
        {
            IBankAccountBuilder builder = CreateBuilder(builderType)
                                          .WithCountry(countryCode, IbanRegistry.Default);

            // Act
            Func <string> act = () => builder.Build();

            // Assert
            act.Should()
            .NotThrow()
            .Which.Should()
            .Be(expected);
        }
        public void Given_country_is_not_set_when_building_it_should_throw(Type builderType)
        {
            string exSource = builderType.Name.Substring(0, 4).ToUpperInvariant();

            IBankAccountBuilder builder = CreateBuilder(builderType);

            // Act
            Action act = () => builder.Build();

            // Assert
            act.Should()
            .ThrowExactly <BankAccountBuilderException>()
            .WithMessage($"The {exSource} cannot be built.")
            .WithInnerException <InvalidOperationException>()
            .WithMessage("The country is required.");
        }
        public void Given_country_does_not_support_branchIdentifier_when_building_it_should_throw(Type builderType)
        {
            string exSource = builderType.Name.Substring(0, 4).ToUpperInvariant();

            IBankAccountBuilder builder = CreateBuilder(builderType)
                                          .WithCountry("NL", IbanRegistry.Default)
                                          .WithBranchIdentifier("123");

            // Act
            Action act = () => builder.Build();

            // Assert
            act.Should()
            .ThrowExactly <BankAccountBuilderException>()
            .WithMessage($"The {exSource} cannot be built.")
            .WithInnerException <InvalidOperationException>()
            .WithMessage("A value for 'Branch' is not supported for country code NL.");
        }
        public void Given_value_is_too_short_and_padding_is_enabled_when_building_it_should_pad_with_zeroes(
            Type builderType,
            Action <IBankAccountBuilder, string, bool> @delegate,
            string countryCode,
            string value,
            string expected
            )
        {
            IBankAccountBuilder builder = CreateBuilder(builderType)
                                          .WithCountry(countryCode, IbanRegistry.Default);

            @delegate(builder, value, true);

            // Act
            Func <string> act = () => builder.Build();

            // Assert
            act.Should()
            .NotThrow()
            .Which.Should().Be(expected);
        }
        public void Given_value_is_too_short_and_padding_is_disabled_when_building_it_should_throw(
            Type builderType,
            Action <IBankAccountBuilder, string, bool> @delegate
            )
        {
            string exSource = builderType.Name.Substring(0, 4).ToUpperInvariant();

            IBankAccountBuilder builder = CreateBuilder(builderType)
                                          .WithCountry("GB", IbanRegistry.Default);

            @delegate(builder, "1", false);

            // Act
            Action act = () => builder.Build();

            // Assert
            act.Should()
            .ThrowExactly <BankAccountBuilderException>()
            .WithMessage($"The {exSource} cannot be built.")
            .WithInnerException <InvalidOperationException>()
            .WithMessage("The value '1' does not have the correct length of *.");
        }
Beispiel #7
0
 public static BankAccount Default(IBankAccountBuilder builder) => builder.Build();