Beispiel #1
0
        public void CheckCountLiveNeighbours()
        {
            UnitTest.Game target = new UnitTest.Game();
            bool[,] board = { { false, false, false }, { false, false, false }, { true, true, true } };
            int liveNeighbours = target.CountLiveNeighbours(board, 1, 1);

            Assert.AreEqual(3, liveNeighbours);

            liveNeighbours = target.CountLiveNeighbours(board, 0, 1);
            Assert.AreEqual(0, liveNeighbours);
            Assert.AreEqual(0, target.CountLiveNeighbours(board, 0, 0));
            Assert.AreEqual(2, target.CountLiveNeighbours(board, 1, 0));
            Assert.AreEqual(2, target.CountLiveNeighbours(board, 1, 2));
            Assert.AreEqual(1, target.CountLiveNeighbours(board, 2, 0));
            Assert.AreEqual(1, target.CountLiveNeighbours(board, 2, 2));
            Assert.AreEqual(3, target.CountLiveNeighbours(board, 1, 1));
            Assert.AreEqual(2, target.CountLiveNeighbours(board, 2, 1));

            Assert.IsTrue(target.IsLiving(board, 2, 0));
            Assert.IsTrue(target.IsLiving(board, 2, 1));
            Assert.IsTrue(target.IsLiving(board, 2, 2));
            Assert.IsFalse(target.IsLiving(board, 1, 0));
            Assert.IsFalse(target.IsLiving(board, 1, 2));
            Assert.IsFalse(target.IsLiving(board, 0, 0));
            Assert.IsFalse(target.IsLiving(board, 0, 1));
            Assert.IsFalse(target.IsLiving(board, 2, 3));
            Assert.IsFalse(target.IsLiving(board, -1, 0));
        }
Beispiel #2
0
        public void ApplyRulesTest()
        {
            UnitTest.Game target = new UnitTest.Game();


            Assert.IsFalse(target.ApplyRules(false, 0));

            Assert.IsFalse(target.ApplyRules(false, 1));

            Assert.IsFalse(target.ApplyRules(false, 2));

            Assert.IsTrue(target.ApplyRules(false, 3));


            Assert.IsFalse(target.ApplyRules(true, 0));

            Assert.IsFalse(target.ApplyRules(true, 1));

            Assert.IsTrue(target.ApplyRules(true, 2));

            Assert.IsTrue(target.ApplyRules(true, 3));

            for (int i = 4; i < 9; i++)
            {
                Assert.IsFalse(target.ApplyRules(true, i));
                Assert.IsFalse(target.ApplyRules(false, i));
            }
        }
Beispiel #3
0
 public void DeadBoardReminsDeadTest()
 {
     UnitTest.Game target = new UnitTest.Game();
     bool[,] board          = new bool[20, 20];
     bool[,] populatedBoard = new bool[20, 20];
     populatedBoard         = target.PopulateBoard(board, ref populatedBoard);
     CollectionAssert.AreEqual(populatedBoard, board);
 }
Beispiel #4
0
 public void BoardChangedTest()
 {
     UnitTest.Game target = new UnitTest.Game();
     bool[,] board          = new bool[20, 20];
     board[0, 0]            = true;
     bool[,] populatedBoard = new bool[20, 20];
     populatedBoard         = target.PopulateBoard(board, ref populatedBoard);
     CollectionAssert.AreNotEqual(populatedBoard, board);
 }
Beispiel #5
0
 public void PlayTest()
 {
     UnitTest.Game target = new UnitTest.Game(); // TODO: Initialize to an appropriate value
     bool[,] board          = new bool[20, 20];
     bool[,] boardAfterPlay = target.Play(board);
     Assert.AreNotSame(board, boardAfterPlay);
     Assert.AreEqual(board.GetLength(0), boardAfterPlay.GetLength(0));
     Assert.AreEqual(board.GetLength(1), boardAfterPlay.GetLength(1));
 }
Beispiel #6
0
 public void CheckLivenessTest()
 {
     UnitTest.Game target = new UnitTest.Game();
     bool[,] board = { { false, false, false }, { false, false, false }, { true, true, true } };
     Assert.IsFalse(target.CheckLiveness(board, 0, 0));
     Assert.IsFalse(target.CheckLiveness(board, 0, 1));
     Assert.IsFalse(target.CheckLiveness(board, 0, 2));
     Assert.IsFalse(target.CheckLiveness(board, 1, 0));
     Assert.IsFalse(target.CheckLiveness(board, 1, 2));
     Assert.IsFalse(target.CheckLiveness(board, 2, 0));
     Assert.IsFalse(target.CheckLiveness(board, 2, 2));
     Assert.IsTrue(target.CheckLiveness(board, 1, 1));
     Assert.IsTrue(target.CheckLiveness(board, 2, 1));
 }