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 ValidationDTO Validate(string token, string cvv, string registrationDateTime) { CheckInputs(token, cvv, registrationDateTime); var registrationDateTimeConverted = Convert.ToDateTime(registrationDateTime); if (!CheckRegistrationDateLimit(registrationDateTimeConverted)) { return new ValidationDTO { Validated = false } } ; var card = _cardRepository.GetCardByRegistrationDate(registrationDateTime); return(new ValidationDTO { Validated = card != null && card.CheckIfTokenIsValid(token, int.Parse(cvv), registrationDateTimeConverted) }); }