Created
April 23, 2019 08:45
-
-
Save jasongorman/c23458c1f123981960bfc70e90c660ee 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(); | |
var payer = new BankAccount(0); | |
var payee = new BankAccount(0); | |
payer.Credit(100); | |
transfer.Transfer(50, payer, payee); | |
Assert.That(payer.Balance, Is.EqualTo(50)); | |
Assert.That(payee.Balance, Is.EqualTo(50)); | |
} | |
} | |
public class BankAccount | |
{ | |
public BankAccount(double balance) | |
{ | |
Balance = balance; | |
} | |
public double Balance { get; private set; } | |
public void Credit(double amount) | |
{ | |
this.Balance += amount; | |
} | |
public void Debit(double amount) | |
{ | |
this.Balance -= amount; | |
} | |
} | |
public class FundsTransfer | |
{ | |
public void Transfer(double amount, BankAccount payer, BankAccount payee) | |
{ | |
payer.Debit(amount); | |
payee.Credit(amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment