Exemplo n.º 1
0
        public void Calculating_For_A_Null_String_Throws_ArgumentNullException()
        {
            var sut = new ModChecksumCalculator(97);

            Action action = () => sut.Calculate(null);

            action.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 2
0
        public void Calculate_Returns_Correct_Result()
        {
            var sut = new ModChecksumCalculator(97);

            sut.Calculate("0").Should().Be(0);
            sut.Calculate("97").Should().Be(0);
            sut.Calculate("3").Should().Be(3);
            sut.Calculate("975").Should().Be(5);
        }
Exemplo n.º 3
0
        /// <summary>
        /// check the iban to make sure that the check digits are correct for the basic bank account number
        /// </summary>
        /// <param name="iban">the iban to check</param>
        internal static bool Validate(ParsingResult iban)
        {
            if (string.IsNullOrEmpty(iban.BasicAccountNumber))
            {
                return(true);
            }
            var rearranged = iban.BasicAccountNumber + iban.CountryCode + iban.CheckDigits;
            var converted  = string.Join("", rearranged.Select(ToInteger));

            var algorithm = new ModChecksumCalculator(97);

            return(algorithm.Validate(converted, 1));
        }