public void Creating_Validating_RandomCardNumbers()
        {
            foreach (var issuer in Enum.GetValues(typeof(CardIssuer)))
            {
                if ((CardIssuer)issuer == CardIssuer.Unknown)
                    continue;

                String number = CreditCardFactory.RandomCardNumber((CardIssuer)issuer);

                CreditCardDetector card = new CreditCardDetector(number);

                Assert.IsTrue(card.Brand == (CardIssuer)issuer,
                    String.Format("card.Brand should be {0}, but is {1}. Number = {2}", issuer, card.Brand, card.CardNumber));

                Assert.IsTrue(card.IsValid((CardIssuer)issuer),
                    String.Format("should be a valid {0} card. Number = {1}", (CardIssuer)issuer, card.CardNumber));

                Assert.IsTrue(card.IsValid(),
                    String.Format("should be a valid card. Brand = {0}, number = {1}", card.Brand, card.CardNumber));

                if ((CardIssuer)issuer != CardIssuer.Visa)
                    Assert.IsFalse(card.IsValid(CardIssuer.Visa),
                        String.Format("card should not be Visa. Brand = {0}, Number = {1}", card.Brand, card.CardNumber));
            }

            /*String number = CreditCardFactory.RandomCardNumber(CardIssuer.MasterCard);

            CreditCardDetector card = new CreditCardDetector(number);

            Assert.IsTrue(card.Brand == CardIssuer.MasterCard);
            Assert.IsTrue(card.IsValid(CardIssuer.MasterCard));
            Assert.IsTrue(card.IsValid());
            Assert.IsFalse(card.IsValid(CardIssuer.Visa));*/
        }
            public void GivenACardIssuer_RandomCardNumber_ReturnsAValidCard(CardIssuer cardIssuer)
            {
                // Arrange.

                // Act.
                var number = CreditCardFactory.RandomCardNumber(cardIssuer);

                // Assert.
                var detector = new CreditCardDetector(number);
                detector.Brand.ShouldBe(cardIssuer);
                detector.IsValid(cardIssuer).ShouldBe(true);
                detector.IsValid().ShouldBe(true);
            }
        public void Validating_CreditCardDetector()
        {
            using (StreamReader r = new StreamReader(@"Data\ValidCards.json"))
            {
                string json = r.ReadToEnd();
                var allCardNumbers = JsonConvert.DeserializeObject<Dictionary<String, String[]>>(json);

                foreach (var cardsBrand in allCardNumbers)
                {
                    foreach (var number in cardsBrand.Value)
                    {
                        CreditCardDetector detector = new CreditCardDetector(number);

                        Assert.IsTrue(detector.IsValid());
                        Assert.AreEqual(cardsBrand.Key, detector.Brand.ToString());
                    }
                }

            }
        }
        public void InvalidNumbers_CreditCardDetector()
        {
            String invalidNumber = "411111-11h1111";

            CreditCardDetector detc = new CreditCardDetector(invalidNumber);
        }