public void StillLife1()
 {
     bool[,] stillLife = new bool[,] { { true, true }, { true, true } };
     Grid board = new Grid(stillLife);
     board.Tick();
     CollectionAssert.AreEqual(stillLife, board.getBoard());
 }
 public void StillLifeTestBeehive()
 {
     bool[,] beehive = new bool[,] { { false, true, true, false }, { true, false, false, true }, { false, true, true, false } };
     Grid board = new Grid(beehive);
     board.Tick();
     CollectionAssert.AreEqual(beehive, board.getBoard());
 }
Beispiel #3
0
        public void CanGenerateNextGenerationWithOneCellGrid()
        {
            IList<Cell> cells = new List<Cell>(new[] { new Cell(0, 0, true) });
            var grid = new Grid(1, cells, 1, 1);

            Assert.IsFalse(grid.Tick().IsAlive(0,0));
        }
Beispiel #4
0
 public void CanGetCellByCoordinates()
 {
     Grid grid = new Grid(50, 50);
     Assert.IsInstanceOfType(typeof(Cell), grid.CellAt(1,1));
     Assert.IsInstanceOfType(typeof(Cell), grid.CellAt(25,25));
     Assert.IsInstanceOfType(typeof(Cell), grid.CellAt(50,50));
 }
Beispiel #5
0
 public Cell(Grid grid, int x, int y)
 {
     _grid = grid;
     _x = x;
     _y = y;
     IsAlive = false;
 }
 public void OscillatorTest()
 {
     bool[,] oscillator = new bool[,] { { false, false, false }, { true, true, true }, { false, false, false } };
     Grid board = new Grid(oscillator);
     board.Tick();
     bool[,] expected = new bool[,] { { false, true, false }, { false, true, false }, { false, true, false } };
     CollectionAssert.AreEqual(expected, board.getBoard());
 }
 public void ToadTest1()
 {
     bool[,] toad = new bool[,] { { false, false, false, false }, {false, true, true, true}, { true, true, true, false }, { false, false, false, false } };
     Grid board = new Grid(toad);
     board.Tick();
     bool[,] expected = new bool[,] { { false, false, true, false }, { true, false, false, true }, { true, false, false, true }, { false, true, false, false } };
     CollectionAssert.AreEqual(expected, board.getBoard());
 }
 public void DiagonalTest1()
 {
     bool[,] diagonal = new bool[,] { { true, false, false }, { false, true, false }, { false, false, true } };
     Grid board = new Grid(diagonal);
     board.Tick();
     bool[,] expected = new bool[,] { { false, false, false }, { false, true, false }, { false, false, false } };
     CollectionAssert.AreEqual(expected, board.getBoard());
 }
 public void BeaconTest1()
 {
     bool[,] beacon = new bool[,] { { true, true, false, false }, { true, true, false, false }, { false, false, true, true }, { false, false, true, true } };
     Grid board = new Grid(beacon);
     board.Tick();
     bool[,] expected = new bool[,] { { true, true, false, false }, { true, false, false, false }, { false, false, false, true }, { false, false, true, true } };
     CollectionAssert.AreEqual(expected, board.getBoard());
 }
Beispiel #10
0
        public void CanGenerateNextGenerationWithLargerGrid()
        {
            IList<Cell> cells = new List<Cell>(new[] { new Cell(1, 4, true), new Cell(2, 3, true), new Cell(2, 4, true)});
            var grid = new Grid(1, cells, 4, 8);

            var nextGen = grid.Tick();
            Assert.That(nextGen.IsAlive(1, 3));
            Assert.That(nextGen.IsAlive(1, 4));
            Assert.That(nextGen.IsAlive(2, 3));
            Assert.That(nextGen.IsAlive(2, 4));
        }
 public void CanCreateInstanceOfGrid()
 {
     Grid MyGrid = new Grid();
     Assert.IsNotNull(MyGrid);
 }
Beispiel #12
0
 public void WidthAndHeightAreSet()
 {
     Grid grid = new Grid(100, 200);
     Assert.AreEqual(100, grid.Width);
     Assert.AreEqual(200, grid.Height);
 }
Beispiel #13
0
 public void GridIsPopulatedWithCells()
 {
     Grid grid = new Grid(50, 50);
     Assert.AreEqual(2500, grid.Cells.Count);
 }