Esempio n. 1
0
        public static ICreditCard RandomCreditCard(string cardNumber, string cardHolder, string cvv = null,
                                                   DateTime?openedDate = null, DateTime?expiryDate = null)
        {
            if (MasterCardCc.IsValidNumber(cardNumber))
            {
                return(new MasterCardCc(cardNumber, cvv, new VocaBase(cardNumber ?? ""), openedDate, expiryDate));
            }
            if (VisaCc.IsValidNumber(cardNumber))
            {
                return(new VisaCc(cardNumber, cvv, new VocaBase(cardNumber ?? ""), openedDate, expiryDate));
            }
            if (AmexCc.IsValidNumber(cardNumber))
            {
                return(new AmexCc(cardNumber, cvv, new VocaBase(cardNumber ?? ""), openedDate, expiryDate));
            }
            if (DiscoverCc.IsValidNumber(cardNumber))
            {
                return(new DiscoverCc(cardNumber, cvv, new VocaBase(cardNumber ?? ""), openedDate, expiryDate));
            }

            throw new ArgumentException($"The card number {cardNumber} does not match any of the defined credit cards.");
        }
Esempio n. 2
0
        public static CreditCardNumber RandomDiscoverNumber()
        {
            var card = new DiscoverCc();

            return(card.GetRandomCardNumber());
        }