Skip to content

Instantly share code, notes, and snippets.

@wahidshalaly
Created April 13, 2010 01:43
Show Gist options
  • Save wahidshalaly/364228 to your computer and use it in GitHub Desktop.
Save wahidshalaly/364228 to your computer and use it in GitHub Desktop.
[Test]
public void Can_deposit_positive_amounts()
{
string name = "Account Name";
string description = "Account Description";
decimal openingBalance = 2500m;
decimal amount = 1000m;
// Given account
var account = new Account(name, description, openingBalance);
// When depositing positive amounts
account.Deposit(amount);
// Then
// 1. Current balance should increase by deposited amount
Assert.AreEqual(openingBalance, account.OpeningBalance);
// 2. Opening balance should stay the same
Assert.AreEqual(openingBalance + amount, account.CurrentBalance);
}
@wahidshalaly
Copy link
Author

Recently, I started to think of test cases in a BDD-like format.
Sometimes, I use Given/When/Then in test case name & sometimes I don't.
I try to keep names smaller & more focused.
For example, this test can be named like: Given_positive_balance_When_deposit_positive_amount_Then_only_current_balance_increases
But I think the short name I used works better. What do u think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment