public void CreditAvailableButReservedTest() { var cardNumber = "4836803436404398198"; string token = string.Empty; _gateway.ReserveCredit(cardNumber, 500m); var sut = new TransactionProcessor(_gateway); sut.PerformFullCreditProcess(cardNumber, 500m, out token); Assert.Equal(string.Empty, token); }
public bool PerformFullCreditProcess( string cardNumber, decimal amount, out string authToken) { authToken = string.Empty; try { _gateway.ValidateCard(cardNumber); } catch (InvalidOperationException) { return(false); } if (_gateway.CheckIfCreditAvailable(cardNumber, amount)) { var id = _gateway.ReserveCredit(cardNumber, amount); if (id == Guid.Empty) { return(false); } else { _gateway.LogReservation(cardNumber, id, amount); authToken = _gateway.CompleteTransaction(cardNumber, id); return(true); } } else { return(false); } }