Added RedirectUsingNamedRoute
[castle.git] / Components / Validator / Castle.Components.Validator.Tests / ValidatorTests / CreditCardValidatorTestCase.cs
blobda00eb23535057a4bcd889f6f81273d8cbbecaac
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Components.Validator.Tests.ValidatorTests
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20 using NUnit.Framework;
22 [TestFixture]
23 public class CreditCardValidatorTestCase
25 #region Credit Card Validator Test
27 [Test]
28 public void CreditCardValidatorTest()
30 Assert.IsTrue(CreditCardValidatorTest(null, CreditCardValidator.CardType.All, new string[] { }));
31 Assert.IsTrue(CreditCardValidatorTest("2323-2005 77663 554", CreditCardValidator.CardType.Unknown, new string[] { }));
32 Assert.IsFalse(CreditCardValidatorTest("3323-2005 77663 554", CreditCardValidator.CardType.Unknown, new string[] { }));
33 Assert.IsFalse(CreditCardValidatorTest("3323-2005 77663 554", CreditCardValidator.CardType.Unknown, new string[] { "3323-2005-7766-3554" }));
34 Assert.IsTrue(CreditCardValidatorTest("3323-2005 77663 554", CreditCardValidator.CardType.Unknown, new string[] { "3323200577663554" }));
35 Assert.IsTrue(CreditCardValidatorTest("4111-1111 1111 1111", CreditCardValidator.CardType.VISA, new string[] { }));
36 Assert.IsTrue(CreditCardValidatorTest("3400-0000 0000009", CreditCardValidator.CardType.Amex, new string[] { }));
37 Assert.IsTrue(CreditCardValidatorTest("3400-0000 0000 009", CreditCardValidator.CardType.Amex, new string[] { }));
38 Assert.IsTrue(CreditCardValidatorTest("6011-0000 00000004", CreditCardValidator.CardType.Discover, new string[] { }));
39 Assert.IsTrue(CreditCardValidatorTest("5500-0000 000 00004", CreditCardValidator.CardType.MasterCard, new string[] { }));
42 private bool CreditCardValidatorTest(string input, CreditCardValidator.CardType allowedTypes, string[] exceptions)
44 CreditCardValidator validator = new CreditCardValidator(allowedTypes, exceptions);
45 return validator.IsValid(this, input);
48 #endregion