예제 #1
0
 public CreditCardControllerTests()
 {
     _logger       = new Mock <ILogger <CreditCardController> >();
     _mediatorMock = new Mock <IMediator>();
     _validInput   = CreditCardGenerator.CreateValidCardInputFaker().Generate();
     _controller   = new CreditCardController(_mediatorMock.Object, _logger.Object);
 }
예제 #2
0
 public CardRegisterCommandHandlerTests()
 {
     _logger          = new Mock <ILogger <CardRegisterCommandHandler> >();
     _respositoryMock = new Mock <ICreditCardRepository>();
     _cardInput       = CreditCardGenerator.CreateValidCardInputFaker().Generate();
     _command         = new CardRegisterCommand(_cardInput);
     _handler         = new CardRegisterCommandHandler(_respositoryMock.Object, _logger.Object);
 }
        public void ShouldReturnValidWhenCardInfoIsValid()
        {
            var card = CreditCardGenerator.CreateValidCardInputFaker().Generate();

            var result = ValidateCard(card);

            Assert.True(result.IsValid);
        }
        public void ShouldReturnInvalidWhenCvcLengthGreaterThan4()
        {
            var card = CreditCardGenerator.CreateValidCardInputFaker()
                       .RuleFor(u => u.Cvc, f => f.Random.String(5))
                       .Generate();

            var result = ValidateCard(card);

            Assert.False(result.IsValid);
        }
        public void ShouldReturnValidWhenCvcLengthIs4()
        {
            var card = CreditCardGenerator.CreateValidCardInputFaker()
                       .RuleFor(u => u.Cvc, f => string.Join("", f.Random.Digits(4)))
                       .Generate();

            var result = ValidateCard(card);

            Assert.True(result.IsValid);
        }
        public void ShouldReturnInvalidWhenCreditCarNumberIsInvalid()
        {
            var card = CreditCardGenerator.CreateValidCardInputFaker()
                       .RuleFor(u => u.CardNumber, f => f.Random.String(11))
                       .Generate();

            var result = ValidateCard(card);

            Assert.False(result.IsValid);
        }
        public void ShouldReturnInvalidWhenNameIsNull()
        {
            var card = CreditCardGenerator.CreateValidCardInputFaker()
                       .RuleFor(u => u.Name, f => null)
                       .Generate();

            var result = ValidateCard(card);

            Assert.False(result.IsValid);
        }
        public void ShouldReturnValidWhenExpiryDateIsToday()
        {
            var card = CreditCardGenerator.CreateValidCardInputFaker()
                       .RuleFor(u => u.ExpiryDate, f => DateTime.Today)
                       .Generate();

            var result = ValidateCard(card);

            Assert.True(result.IsValid);
        }
        public void ShouldReturnInvalidWhenExpiryDateIsBeforeToday()
        {
            var card = CreditCardGenerator.CreateValidCardInputFaker()
                       .RuleFor(u => u.ExpiryDate, f => f.Date.Past())
                       .Generate();

            var result = ValidateCard(card);

            Assert.False(result.IsValid);
        }