Example #1
0
        public void GivingInvalidState_HasInvalidValues()
        {
            var card = new CreditCard {Number = "1234567890123456", Ean = "9782266156067"};
            var classValidator = GetClassValidator(typeof(CreditCard));

            classValidator.GetInvalidValues(card).Should().Have.Count.EqualTo(2);
        }
Example #2
0
        public void GivingValidState_NoInvalidValues()
        {
            var card = new CreditCard {Number = "541234567890125", Ean = "9782266156066"};
            var classValidator = GetClassValidator(typeof(CreditCard));

            classValidator.GetInvalidValues(card).Should().Be.Empty();
        }
Example #3
0
 public void CreditCard()
 {
     CreditCard card = new CreditCard();
     card.number = "1234567890123456";
     IClassValidator classValidator = GetClassValidator(typeof(CreditCard));
     InvalidValue[] invalidValues = classValidator.GetInvalidValues(card);
     Assert.AreEqual(1, invalidValues.Length);
     card.number = "541234567890125"; //right CC (luhn compliant)
     invalidValues = classValidator.GetInvalidValues(card);
     Assert.AreEqual(0, invalidValues.Length);
     card.ean = "9782266156066"; //right EAN
     invalidValues = classValidator.GetInvalidValues(card);
     Assert.AreEqual(0, invalidValues.Length);
     card.ean = "9782266156067"; //wrong EAN
     invalidValues = classValidator.GetInvalidValues(card);
     Assert.AreEqual(1, invalidValues.Length);
 }