public void GridConstructorTest1() { bool[,] cells = {{true, true, true, false, false, false}, {true, true, true, false, false, true}, {true, true, true, false, false, false}}; Grid target = new Grid(cells); Assert.AreEqual(cells.GetLength(0), target.Height, "Height improperly set"); Assert.AreEqual(cells.GetLength(1), target.Width, "Width improperly set"); for (int i = 0; i < cells.GetLength(1); ++i) { for (int j = 0; j < cells.GetLength(0); j++) { Assert.AreEqual(cells[j, i], target.GetCell(i, j)); } } }
public void StepTest() { bool[,] cells = {{true, true, true, false, false, true}, {true, true, true, false, false, true}, {true, true, true, false, false, true}}; Grid target = new Grid(cells); target.Step(); //Top Row vals Assert.AreEqual(false, target.GetCell(0, 0)); Assert.AreEqual(false, target.GetCell(1, 0)); Assert.AreEqual(true, target.GetCell(2, 0)); //Bottom Row vals Assert.AreEqual(false, target.GetCell(0, 4)); Assert.AreEqual(false, target.GetCell(1, 4)); Assert.AreEqual(true, target.GetCell(2, 4)); //Left col Assert.AreEqual(false, target.GetCell(1, 0)); Assert.AreEqual(true, target.GetCell(2, 0)); Assert.AreEqual(false, target.GetCell(3, 0)); Assert.AreEqual(false, target.GetCell(4, 0)); //Right col Assert.AreEqual(false, target.GetCell(7, 0)); Assert.AreEqual(false, target.GetCell(7, 1)); Assert.AreEqual(true, target.GetCell(7, 2)); Assert.AreEqual(true, target.GetCell(4, 2), "Reproduction failed"); Assert.AreEqual(false, target.GetCell(6, 1), "Death by undercrowding failed"); Assert.AreEqual(false, target.GetCell(5, 1), "Stay dead failed"); Assert.AreEqual(true, target.GetCell(5, 2), "Reproduction failed"); Assert.AreEqual(true, target.GetCell(6, 2), "Keep alive failed"); }