Esempio n. 1
0
        public void TestCardNumber4()
        {
            // TODO: Add your test code here
            string CardNumber = "abcdefghijklmnop";

            IsCardNumberValid IsCardValid = new IsCardNumberValid(CardNumber);

            Assert.IsTrue(!IsCardValid.Validate());
        }
Esempio n. 2
0
        public void TestCardNumber3()
        {
            // TODO: Add your test code here
            string CardNumber = "411111111111111a";

            IsCardNumberValid IsCardValid = new IsCardNumberValid(CardNumber);

            Assert.IsTrue(!IsCardValid.Validate());
        }
        public void CreditCardValidation_CheckValidDiscoverCreditCardNumberWith16Digits_ReturnsTureifValid()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("6011111111111117");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(true, actual);
        }
        public void CreditCardValidation_CheckValidAmexCreditCardNumberWith15Digits_ReturnsTureifValid()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("378282246310005");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(true, actual);
        }
        public void CreditCardValidation_CheckValidVisaCreditCardNumberWith13Digits_ReturnsTureifValid()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("4111111111111");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(false, actual);
        }
        public void CreditCardValidation_CheckCreditCardNumberContainOtherDigits_ReturnsFlase()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("4012888888abc881");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(false, actual);
        }
        public void CreditCardValidation_CheckCreditCardNumberContainDecimals_ReturnsFalseOnDicimals()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("41111111111111.1");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(false, actual);
        }
        public void CreditCardValidation_CheckInvalidCreditCardNumber_ReturnsFlaseIfInvalid()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("9111111111111111");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(false, actual);
        }
        public void CreditCardValidation_CheckInValidMasterCreditCardNumberWith16Digits_ReturnsFalseifInValid()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("5105105105105106");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(false, actual);
        }
        public void CreditCardValidation_CheckCreditCardNumberContainOnlyDigits_ReturnsTrueOnDigitsOnly()
        {
            //Arrange
            _CreditCardNumber = new IsCardNumberValid("4111111111111111");
            bool actual = false;

            //Act
            actual = _CreditCardNumber.Validate();
            //Assert
            Assert.AreEqual(true, actual);
        }
        public bool Validate()
        {
            bool _result        = false;
            var  cardNumberRule = new IsCardNumberValid(_cardNumber);
            var  expiryDateRule = new IsValidExpiryDate(_expiryYear, _expiryMonth);

            try
            {
                _result = cardNumberRule.Validate() && expiryDateRule.Validate();
            }
            catch (System.Exception ex)
            {
                mylog.Error(ex);
            }
            return(_result);
        }
Esempio n. 12
0
        public void TestCardNumberValidVisa()
        {
            IsCardNumberValid _isCardNumberValid = new IsCardNumberValid("4012888888881881");

            Assert.AreEqual(true, _isCardNumberValid.Validate(), "Accepts sample visa card");
        }
Esempio n. 13
0
        public void TestCardNumbeNull()
        {
            IsCardNumberValid _isCardNumberValid = new IsCardNumberValid(null);

            Assert.AreEqual(false, _isCardNumberValid.Validate(), "Rejects null card nulmer");
        }
Esempio n. 14
0
        public void TestCardNumberInvalid()
        {
            IsCardNumberValid _isCardNumberValid = new IsCardNumberValid("6037991391528422");

            Assert.AreEqual(false, _isCardNumberValid.Validate(), "Rejects invalid card nulmer ");
        }
Esempio n. 15
0
        public void TestCardNumberInvalidLengthSmaller()
        {
            IsCardNumberValid _isCardNumberValid = new IsCardNumberValid("603799139152842");

            Assert.AreEqual(false, _isCardNumberValid.Validate(), "Rejects card nulmer with invalid length");
        }
Esempio n. 16
0
        public void TestCardNumberValidMaster()
        {
            IsCardNumberValid _isCardNumberValid = new IsCardNumberValid("5555555555554444");

            Assert.AreEqual(true, _isCardNumberValid.Validate(), "Accepts sample master card");
        }