コード例 #1
0
        /// <summary>
        /// Calculates the check digit. The given bank code will be
        /// mapped to an registered method which calculates the check digit.
        /// The account number is given without a check digit.
        /// </summary>
        /// <param name="accountNumber">The account number without a check digit.</param>
        /// <returns>
        /// The calculated check digit for the given account number
        /// </returns>
        public string CalculateCheckDigit(NationalAccountNumber accountNumber)
        {
            if (accountNumber == null)
            {
                throw new ArgumentNullException("accountNumber", "Please provide an account number.");
            }

            var germanAccountNumber = new GermanyAccountNumber(accountNumber);

            var checkMethodCode = BankCodeMappingMethod.Resolve(germanAccountNumber.BankCode);

            if (string.IsNullOrEmpty(checkMethodCode))
            {
                throw new ArgumentException(String.Format("Can't resolve the check method for the given bank code {0}.", germanAccountNumber.BankCode), "accountNumber");
            }

            return(accountNumberValidationByMethodCode.CalculateCheckDigit(germanAccountNumber.AccountNumber, checkMethodCode));
        }
コード例 #2
0
        public void Should_Calculate_A_Digit_With_Method01()
        {
            IAccountNumberValidationByMethodCode sut = SuT;

            Assert.AreEqual("7", sut.CalculateCheckDigit("423432278", "01"));
        }