public void Should_validate_account_and_payment_request() { const string accountNumber = "12312312ABC"; var request = new MakePaymentRequest { PaymentScheme = PaymentScheme.Bacs, DebtorAccountNumber = accountNumber }; var account = accountBuilder .WithAccountNumberAs(accountNumber) .Build(); config.DataStoreType.Returns(DataStoreType.Account); accountDataStore.GetAccount(Arg.Any <string>()).Returns(account); var paymentService = CreateService(); paymentService.MakePayment(request); bacsValidator.Received(1).Validate(account, request); }
public MakePaymentResult MakePayment(MakePaymentRequest request) { var account = accountDataStore.GetAccount(request.DebtorAccountNumber); var validator = paymentRequestValidators[request.PaymentScheme]; var result = validator.Validate(account, request); if (result.Success) { var transaction = new Transaction( request.Amount, TransactionType.Withdrawal); account.AddTransaction(transaction); accountDataStore.UpdateAccount(account); } return(result); }