コード例 #1
0
        public async Task ValidateAsync_WhenValid_Ok()
        {
            var card      = CreateValidCard();
            var validator = new CreditCardValidator();

            var result = await validator.ValidateAsync(card);

            Assert.True(result.IsValid);
        }
コード例 #2
0
        public async Task ValidateAsync_WhenExpiryMonthOutOfBounds_IsInvalid(int expiryMonth)
        {
            var card = CreateValidCard();

            card.ExpiryMonth = expiryMonth;
            var validator = new CreditCardValidator();

            var result = await validator.ValidateAsync(card);

            Assert.False(result.IsValid);
        }
コード例 #3
0
        public async Task ValidateAsync_WhenCCV4Digits_IsValid(string ccv)
        {
            var card = CreateValidCard();

            card.CCV = ccv;
            var validator = new CreditCardValidator();

            var result = await validator.ValidateAsync(card);

            Assert.True(result.IsValid);
        }
コード例 #4
0
        public async Task ValidateAsync_WhenCardNumberValid_IsValid(string cardNumber)
        {
            var card = CreateValidCard();

            card.CardNumber = cardNumber;
            var validator = new CreditCardValidator();

            var result = await validator.ValidateAsync(card);

            Assert.True(result.IsValid);
        }
コード例 #5
0
        public async Task ValidateAsync_WhenNameOnCardInvalid_IsInvalid(string name)
        {
            var card = CreateValidCard();

            card.NameOnCard = name;
            var validator = new CreditCardValidator();

            var result = await validator.ValidateAsync(card);

            Assert.False(result.IsValid);
        }
コード例 #6
0
        public async Task ValidateAsync_WhenExpiryYearInvalid_IsInvalid(int expiryYear)
        {
            var card = CreateValidCard();

            card.ExpiryYear = expiryYear;
            var validator = new CreditCardValidator();

            var result = await validator.ValidateAsync(card);

            Assert.False(result.IsValid);
        }