Created
April 23, 2019 08:19
-
-
Save jasongorman/7e82cd95419ed3977d029e6ad3ec0be3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class TransferTests | |
{ | |
[Test] | |
public void AmountTransferredFromPayerToPayee() | |
{ | |
var transfer = new FundsTransfer(); | |
// initialise accounts | |
var payerBalance = transfer.InitAccount(); | |
var payeeBalance = transfer.InitAccount(); | |
// credit payer with funds to allow transfer | |
transfer.Credit(ref payerBalance, 100); | |
// transfer 50 | |
transfer.Transfer(ref payerBalance, ref payeeBalance, 50); | |
Assert.That(payerBalance, Is.EqualTo(50)); | |
Assert.That(payeeBalance, Is.EqualTo(50)); | |
} | |
} | |
public class FundsTransfer | |
{ | |
public double InitAccount() | |
{ | |
double balance = 0; | |
return balance; | |
} | |
public void Transfer(ref double payerBalance, ref double payeeBalance, double amount) | |
{ | |
Debit(ref payerBalance, amount); | |
Credit(ref payeeBalance, amount); | |
} | |
public void Credit(ref double balance, double amount) | |
{ | |
balance += amount; | |
} | |
public void Debit(ref double balance, double amount) | |
{ | |
balance -= amount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment