public void ValidExpiryReturnsTrue() { string expiry = $"12/{_thisYear}"; Assert.True( ExpiryValidator.Validate(expiry)); }
public void InvalidExpiryLengthReturnsFalse() { string expiry = $"122/{_thisYear}"; Assert.False( ExpiryValidator.Validate(expiry)); }
public void InvalidExpiryYearUpperRangReturnsFalse() { string expiry = $"22/{_thisYear + 11}"; Assert.False( ExpiryValidator.Validate(expiry)); }
public void InvalidExpiryMarkerReturnsFalse() { string expiry = $"12-{_thisYear}"; Assert.False( ExpiryValidator.Validate(expiry)); }
/// <summary> /// Simulates a payment authorization, invalid expiry or card number or a payment does not match the payment policy returns false as status /// </summary> /// <param name="paymentAuthorizationRequest"></param> /// <returns>Indicating the current payment authorization response in <see cref="PaymentAuthorizationResponse"/>.</returns> public PaymentAuthorizationResponse AuthorizePayment( PaymentAuthorizationRequest paymentAuthorizationRequest) { // Check payment based on the payment policy if (_paymentPolicy.MaxAllowedAmount < paymentAuthorizationRequest.Amount || _paymentPolicy.MinAllowedAmount > paymentAuthorizationRequest.Amount || _paymentPolicy.AllowedCurrencies.Count(c => c.Code == paymentAuthorizationRequest.Currency) == 0 || !ExpiryValidator.Validate(paymentAuthorizationRequest.Expiry) || !CardNumberValidator.Validate(paymentAuthorizationRequest.CardNumber)) { return(new PaymentAuthorizationResponse(Guid.NewGuid(), false)); } return(new PaymentAuthorizationResponse(Guid.NewGuid(), true)); }