Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created April 23, 2019 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/c23458c1f123981960bfc70e90c660ee to your computer and use it in GitHub Desktop.
Save jasongorman/c23458c1f123981960bfc70e90c660ee to your computer and use it in GitHub Desktop.
[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