Skip to content

Instantly share code, notes, and snippets.

@joshilewis
Created December 8, 2015 07:44
Show Gist options
  • Save joshilewis/d12df84af210e6ca4d59 to your computer and use it in GitHub Desktop.
Save joshilewis/d12df84af210e6ca4d59 to your computer and use it in GitHub Desktop.
How I do TDD
[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