public ValidationResponse Validate(string entry, ICardNetwork cardNetwork, List<CardNetwork> acceptableCardNetworksForTransaction) { int i; entry = entry ?? string.Empty; var valid = int.TryParse(entry, out i) && entry.Length == cardNetwork.GetSecurityCodeLength(); var errorMessage = string.Empty; if (!valid && entry.Length >= cardNetwork.GetSecurityCodeLength()) { errorMessage = "Check security code"; } return new ValidationResponse(valid, errorMessage, !string.IsNullOrWhiteSpace(errorMessage)); }
private void AssertCardNetwork(ICardNetwork actualCardNetwork, CardNetwork cardNetwork, string securityCode, int securityCodeLength, int cardNumberLength, bool shouldDisplayStartDate, bool shouldDisplayIssueNumber) { Assert.That(actualCardNetwork.GetCardNetworkType(), Is.EqualTo(cardNetwork)); Assert.That(actualCardNetwork.GetSecurityCodeLabel(), Is.EqualTo(securityCode)); Assert.That(actualCardNetwork.GetSecurityCodeLength(), Is.EqualTo(securityCodeLength)); Assert.That(actualCardNetwork.GetCardNumberLength(), Is.EqualTo(cardNumberLength)); Assert.That(actualCardNetwork.ShouldDisplayStartDate(), Is.EqualTo(shouldDisplayStartDate)); Assert.That(actualCardNetwork.ShouldDisplayIssueNumber(), Is.EqualTo(shouldDisplayIssueNumber)); }