public void Should_validate_an_invalid_registration_date_time() { var number = "1111333355557777"; var cvv = "7888"; var card = CardBuilder.New() .WithNumber(number) .WithCvv(cvv) .Build(); var invalidRegistrationDateTime = DateTime.UtcNow.AddMinutes(-20); var validationDto = _cardValidation.Validate(card.Token, card.Cvv, invalidRegistrationDateTime.ToStringWithMiliseconds()); Assert.IsFalse(validationDto.Validated); }
public void Should_validate_a_valid_card_token_and_registration_date_time() { var number = "1111333355557777"; var cvv = "7888"; var card = CardBuilder.New() .WithNumber(number) .WithCvv(cvv) .Build(); _cardRepository.GetCardByRegistrationDate(card.RegistrationDateTime.ToStringWithMiliseconds()).Returns(card); var validationDto = _cardValidation.Validate(card.Token, card.Cvv, card.RegistrationDateTime.ToStringWithMiliseconds()); Assert.IsTrue(validationDto.Validated); }
public void Should_validate_an_non_existent_card_for_registration_date() { var number = "1111333355557777"; var cvv = "7888"; var card = CardBuilder.New() .WithNumber(number) .WithCvv(cvv) .Build(); var registrationDateTime = DateTime.UtcNow; _cardRepository.GetCardByRegistrationDate(Arg.Any <string>()).ReturnsNull(); var validationDto = _cardValidation.Validate(card.Token, card.Cvv, registrationDateTime.ToStringWithMiliseconds()); Assert.IsFalse(validationDto.Validated); }
public void Should_create_a_card() { var card = CardBuilder.New() .WithNumber(_cardNumber) .WithCvv(_cvv) .Build(); var cardExpected = new CardDTO { Token = card.Token, RegistrationDate = card.RegistrationDateTime.ToStringWithMiliseconds() }; var cardCreated = _cardCreator.CreateNewCard(_cardNumber, _cvv); Assert.AreEqual(cardExpected.Token, cardCreated.Token); Assert.That(Convert.ToDateTime(cardExpected.RegistrationDate), Is.EqualTo(card.RegistrationDateTime).Within(1).Seconds); }
public void Should_validate_an_invalid_card_token() { var oneNumber = "12345678901234"; var otherNumber = "2345678901234579"; var oneCvv = "7888"; var otherCvv = "7899"; var oneCard = CardBuilder.New() .WithNumber(oneNumber) .WithCvv(oneCvv) .Build(); var otherCard = CardBuilder.New() .WithNumber(otherNumber) .WithCvv(otherCvv) .Build(); _cardRepository.GetCardByRegistrationDate(oneCard.RegistrationDateTime.ToStringWithMiliseconds()).Returns(otherCard); var validationDto = _cardValidation.Validate(oneCard.Token, oneCard.Cvv, oneCard.RegistrationDateTime.ToStringWithMiliseconds()); Assert.IsFalse(validationDto.Validated); }