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."); }
public static CreditCardNumber RandomAmexNumber() { var card = new AmexCc(); return(card.GetRandomCardNumber()); }