public void TestCardTypeValidator()
    {
        var result = CreditCardValidator.ValidCardNumber("4852461030260066", new ICardTypeValidator[]
        {
            new WellsFargoBankValidator()
        });

        Assert.IsTrue(result.CardNumberFormat == CardNumberFormat.Valid_BINTest && result.CardTypes.Contains("Wells Fargo Bank"));
    }
Exemple #2
0
    public void TestGenerateCardNumber()
    {
        var bin    = "485246";
        int length = 16;
        var cn     = CreditCardGenerator.GenerateCardNumber(bin, length);

        Assert.IsNotEmpty(cn);
        Assert.IsTrue(cn.Length == length);

        var result = CreditCardValidator.ValidCardNumber(cn);

        Assert.IsTrue(result.CardNumberFormat == CardNumberFormat.Valid_LuhnOnly ||
                      result.CardNumberFormat == CardNumberFormat.Valid_BINTest);
    }
    public void TestValidMasterCard()
    {
        var result = CreditCardValidator.ValidCardNumber("5105105105105100");

        Assert.IsTrue(result.CardNumberFormat == CardNumberFormat.Valid_BINTest && result.CardTypes.Contains("MasterCard"));
    }
    public void TestValidVisa()
    {
        var result = CreditCardValidator.ValidCardNumber("4012888888881881");

        Assert.IsTrue(result.CardNumberFormat == CardNumberFormat.Valid_BINTest && result.CardTypes.Contains("Visa"));
    }
    public void TestLuhnMod10Success()
    {
        var result = CreditCardValidator.ValidCardNumber("214916279426729");

        Assert.IsTrue(result.CardNumberFormat == CardNumberFormat.Valid_LuhnOnly);
    }
    public void TestLuhnMod10Failure()
    {
        var result = CreditCardValidator.ValidCardNumber("9962514040073500");

        Assert.IsTrue(result.CardNumberFormat == CardNumberFormat.Invalid_LuhnFailure);
    }
    public void TestInvalidCardNumberFormat(string cardNumber)
    {
        var result = CreditCardValidator.ValidCardNumber(cardNumber);

        Assert.IsTrue(result.CardNumberFormat == CardNumberFormat.Invalid_BadStringFormat);
    }