Skip to content

Instantly share code, notes, and snippets.

@aevitas
Created July 8, 2014 20:12
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 aevitas/944b21b524a93c2e47f4 to your computer and use it in GitHub Desktop.
Save aevitas/944b21b524a93c2e47f4 to your computer and use it in GitHub Desktop.
[Subject(typeof(Inventory), "customer swapping garment")]
public class GarmentSpecifications
{
private static Inventory _inventory;
Establish context = () =>
{
// Establish the context for our test case, set up the required objects, etc.
_inventory = new Inventory();
_inventory.Add(GarmentColor.Black, 3);
_inventory.Add(GarmentColor.Blue, 2);
};
// The mutation our test case performs, which should produce the asserted result.
// The "Because" (or Act) block should be the _only_ block to modify state!
Because of = () => _inventory.TradeIn(GarmentColor.Blue, GarmentColor.Black);
// We assert whether our premises are indeed correct.
It should_have_three_blue_garments_in_stock = () => _inventory.Stock[GarmentColor.Blue].ShouldEqual(3);
It should_have_two_black_garments_in_stock = () => _inventory.Stock[GarmentColor.Black].ShouldEqual(2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment