Beispiel #1
0
        public async void CardType_Create_null()
        {
            Mock <ICreditCardRepository> creditCardRepository = new Mock <ICreditCardRepository>();

            creditCardRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new CreditCard()));

            var validator = new ApiCreditCardRequestModelValidator(creditCardRepository.Object);
            await validator.ValidateCreateAsync(new ApiCreditCardRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.CardType, null as string);
        }
Beispiel #2
0
        private async void BeUniqueByCardNumber_Create_Not_Exists()
        {
            Mock <ICreditCardRepository> creditCardRepository = new Mock <ICreditCardRepository>();

            creditCardRepository.Setup(x => x.ByCardNumber(It.IsAny <string>())).Returns(Task.FromResult <CreditCard>(null));
            var validator = new ApiCreditCardRequestModelValidator(creditCardRepository.Object);

            await validator.ValidateCreateAsync(new ApiCreditCardRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.CardNumber, "A");
        }