Created
July 7, 2014 02:56
-
-
Save stjanovitz/c74bd49a21767cf08283 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
using System; | |
using NUnit.Framework; | |
namespace bank | |
{ | |
public class Account | |
{ | |
private float balance; | |
public void Deposit(float amount) | |
{ | |
balance += amount; | |
} | |
public void Withdraw(float amount) | |
{ | |
balance -= amount; | |
} | |
public void TransferFunds(Account destination, float amount) | |
{ | |
} | |
public float Balance | |
{ | |
get { return balance; } | |
} | |
} | |
} | |
namespace bank | |
{ | |
[TestFixture] | |
public class AccountTest | |
{ | |
[Test] | |
public void TransferFunds() | |
{ | |
Account source = new Account(); | |
source.Deposit(200.00F); | |
Account destination = new Account(); | |
destination.Deposit(150.00F); | |
source.TransferFunds(destination, 100.00F); | |
Assert.AreEqual(250.00F, destination.Balance); | |
Assert.AreEqual(100.00F, source.Balance); | |
} | |
[Test] | |
public void DepositFunds() | |
{ | |
Account source = new Account(); | |
source.Deposit(200.00F); | |
Assert.AreEqual(200.00F, source.Balance); | |
} | |
} | |
} | |
namespace UnitTestDemo | |
{ | |
public class MyAccountingSoftware | |
{ | |
public static void Main() | |
{ | |
bank.Account DemoAccount = new bank.Account(); | |
DemoAccount.Deposit(1000.00F); | |
DemoAccount.Withdraw(500.50F); | |
Console.WriteLine("Our account balance is {0}", DemoAccount.Balance); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment