/// <summary>
        /// Calculates the check digit for the given credit card number.
        /// </summary>
        /// <param name="creditCardNumber">The credit card number.</param>
        /// <param name="creditCardNetwork">The credit card network.</param>
        /// <exception cref="ArgumentNullException">is thrown, if an argument isn't provided</exception>
        /// <exception cref="ArgumentException">is thrown, if the credit card network can't be automatically detected</exception>
        /// <exception cref="InvalidOperationException">is thrown, if there is a problem with the mapping of the network to a check method</exception>
        /// <returns></returns>
        public string CalculateCheckDigit(string creditCardNumber, string creditCardNetwork)
        {
            if (creditCardNetwork == null)
            {
                throw new ArgumentNullException("creditCardNetwork", "Please provide a credit card network code for a check method.");
            }
            if (string.IsNullOrEmpty(creditCardNumber))
            {
                throw new ArgumentNullException("creditCardNumber", "Please provide a credit card number.");
            }

            if (CreditCardNetworkMapToMethod == null)
            {
                throw new InvalidOperationException("Please provide an instanz for the mapping between a check method code and a check method.");
            }

            creditCardNumber = CleanUp(creditCardNumber);

            if (creditCardNetwork == CreditCardNetwork.Automatic)
            {
                creditCardNetwork = CreditCardNumberMapToNetwork.Resolve(creditCardNumber);
                if (string.IsNullOrEmpty(creditCardNetwork))
                {
                    throw new ArgumentException("Please provide a specific credit card network identifier because it can not be resolved from the given credit card number.", "creditCardNetwork");
                }
            }

            var checkMethod = CreditCardNetworkMapToMethod.Resolve(creditCardNetwork);

            if (checkMethod == null)
            {
                throw new InvalidOperationException(String.Format("The credit card network code {0} could not be mapped to a check method implementation.", creditCardNetwork));
            }

            return(checkMethod.CalculateCheckDigit(creditCardNumber));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreditCardNumberCheck"/> class.
 /// </summary>
 /// <param name="creditCardNetworkMapToMethod">The credit card network code map to method.</param>
 public CreditCardNumberCheck(ICreditCardNetworkMapToMethod creditCardNetworkMapToMethod)
 {
     CreditCardNetworkMapToMethod = creditCardNetworkMapToMethod;
     CreditCardNumberMapToNetwork = new CreditCardNumberMapToNetwork();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreditCardNumberCheck"/> class.
 /// </summary>
 public CreditCardNumberCheck()
 {
     CreditCardNetworkMapToMethod = new CreditCardNetworkMapToMethodFactory();
     CreditCardNumberMapToNetwork = new CreditCardNumberMapToNetwork();
 }