public void CheckRanges()
        {
            foreach (var range in this.Ranges)
            {
                CardIssuer ci = range.Range.CreditCardBrandIgnoreLength();

                (ci.ToString().ToLower() == range.CardIssuer.ToLower()).ShouldBe(true);
            }
        }
        public void CheckRanges()
        {
            foreach (var range in this.Ranges)
            {
                CardIssuer ci = range.Range.CreditCardBrandIgnoreLength();

                (ci.ToString().ToLower() == range.CardIssuer.ToLower()).ShouldBe(true);
                //if (cardDetector.Brand.ToString().ToLower() != range.CardIssuer.ToLower())
                //    throw new Exception();
            }
        }
        public static List <int> Lengths(CardIssuer cardIssuer)
        {
            var lengths = new List <int>();

            foreach (var item in Lengths()
                     .SelectMany(item => item.Cast <KeyValuePair <string, List <int> > >())
                     .Where(x => x.Key.Equals(cardIssuer.ToString(), StringComparison.OrdinalIgnoreCase)))
            {
                lengths = item.Value;
            }

            return(lengths);
        }
        public static TheoryData <KeyValuePair <string, string[]> > CreditCards(CardIssuer cardIssuer)
        {
            var theoryData = new TheoryData <KeyValuePair <string, string[]> >();

            foreach (var creditCard in CreditCards()
                     .SelectMany(item => item.Cast <KeyValuePair <string, string[]> >())
                     .Where(x => x.Key.Equals(cardIssuer.ToString(), StringComparison.OrdinalIgnoreCase)))
            {
                theoryData.Add(creditCard);
            }

            return(theoryData);
        }
示例#5
0
            public void GivenACardIssuer_RandomCardNumber_ReturnsAValidCard_Length_Invalid(CardIssuer cardIssuer)
            {
                // Arrange.
                string    number = "";
                Exception e      = new Exception();

                // Act.
                try
                {
                    number = CreditCardFactory.RandomCardNumber(cardIssuer, 99);
                }
                catch (Exception ex)
                {
                    e = ex;
                }

                // Assert
                e.ShouldBeOfType <ArgumentException>();
                e.Message.ShouldBe("99 is not valid length for card issuer " + cardIssuer.ToString());
                number.Length.ShouldBe(0);
            }
示例#6
0
 public static ImageSource GetIconImageSource(CardIssuer issuer) => ImageSource.FromFile(
     issuer.IsAccepted() ? issuer.ToString().PascalToSnakeCase() : (ThemeEngine.IsEffectivelyLight ? "unknown_light" : "unknown_dark") + ".png");
        public static TheoryData<KeyValuePair<string, string[]>> CreditCards(CardIssuer cardIssuer)
        {
            var theoryData = new TheoryData<KeyValuePair<string, string[]>>();
            foreach (var creditCard in CreditCards()
                .SelectMany(item => item.Cast<KeyValuePair<string, string[]>>())
                .Where(x => x.Key.Equals(cardIssuer.ToString(), StringComparison.OrdinalIgnoreCase)))
            {
                theoryData.Add(creditCard);
            }

            return theoryData;
        }