public void GridConstructorTest() { Random random = new Random(); int width = random.Next(1, 1000); int height = random.Next(1, 1000); Grid target = new Grid(width, height); Assert.AreEqual(width, target.Width, "Width is not properly set after constructor"); Assert.AreEqual(height, target.Height, "Width is not properly set after constructor"); }
public override void Initialize() { bool[,] testVals = {{true, true, true, false, false, false}, {true, true, true, false, false, true}, {true, true, true, false, false, false}}; _Grid = new Grid(testVals); _Visuals = new List<IVisual>(); _Visuals.Capacity = _Grid.Height + _Grid.Width + 2; _LastWidth = -1; _LastHeight = -1; hasStepped = false; }
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 StepTest2() { bool[,] cells = {{false ,false ,false ,false ,false ,false ,false } , {false ,false ,false ,false ,false ,false ,false } , {false ,false ,false ,true ,true ,true ,false } , {false ,false ,true ,false ,false ,false ,true } , {false ,false ,true ,false ,false ,false ,true } , {false ,false ,true ,false ,false ,false ,true } , {false ,false ,false ,true ,true ,true ,false } }; Grid target = new Grid(cells); target.Step(); }
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"); }