Created
December 8, 2015 07:44
-
-
Save joshilewis/d12df84af210e6ca4d59 to your computer and use it in GitHub Desktop.
How I do TDD
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
[Test] | |
public void Test_Barge() | |
{ | |
var initialGrid = new char[,] | |
{ | |
{'.', '.', '.', '.', '.', '.'}, | |
{'.', '.', '*', '.', '.', '.'}, | |
{'.', '*', '.', '*', '.', '.'}, | |
{'.', '.', '*', '.', '*', '.'}, | |
{'.', '.', '.', '*', '.', '.'}, | |
{'.', '.', '.', '.', '.', '.'}, | |
}; | |
Game.PrintGrid(initialGrid); | |
var game = CreateGame(initialGrid); | |
game.Tick(); | |
char[,] generation = game.Grid; | |
Assert.That(generation, Is.EqualTo(initialGrid)); | |
} | |
[Test] | |
public void Test_Blinker() | |
{ | |
var initialGrid = new char[,] | |
{ | |
{'.', '.', '.'}, | |
{'*', '*', '*'}, | |
{'.', '.', '.'}, | |
}; | |
var expectedGeneration1 = new char[,] | |
{ | |
{'.', '*', '.'}, | |
{'.', '*', '.'}, | |
{'.', '*', '.'}, | |
}; | |
var expectedGeneration2 = new char[,] | |
{ | |
{'.', '.', '.'}, | |
{'*', '*', '*'}, | |
{'.', '.', '.'}, | |
}; | |
var game = CreateGame(initialGrid); | |
Game.PrintGrid(initialGrid); | |
game.Tick(); | |
char[,] actualGeneration = game.Grid; | |
Assert.That(actualGeneration, Is.EqualTo(expectedGeneration1)); | |
game.Tick(); | |
actualGeneration = game.Grid; | |
Assert.That(actualGeneration, Is.EqualTo(expectedGeneration2)); | |
} | |
[Test] | |
public void Test_Glider() | |
{ | |
var initialGrid = new char[,] | |
{ | |
{'.', '*', '.'}, | |
{'.', '.', '*'}, | |
{'*', '*', '*'}, | |
}; | |
var expectedGeneration1 = new char[,] | |
{ | |
{'.', '.', '.'}, | |
{'*', '.', '*'}, | |
{'.', '*', '*'}, | |
{'.', '*', '.'}, | |
}; | |
var expectedGeneration2 = new char[,] | |
{ | |
{'.', '.', '.'}, | |
{'.', '.', '*'}, | |
{'*', '.', '*'}, | |
{'.', '*', '*'}, | |
}; | |
var game = CreateGame(initialGrid); | |
Game.PrintGrid(initialGrid); | |
game.Tick(); | |
char[,] actualGeneration = game.Grid; | |
Assert.That(actualGeneration, Is.EqualTo(expectedGeneration1)); | |
game.Tick(); | |
actualGeneration = game.Grid; | |
Assert.That(actualGeneration, Is.EqualTo(expectedGeneration2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment