Esempio n. 1
0
        public void MakeMoveTest()
        {
            //Create a new board and make a move in it
            TTTBoard board = new TTTBoard();

            board.MakeMove(new TTTMove(1, 0));

            //Check that the move was made correctly
            Assert.AreEqual(1, board.GetCell(1, 0));

            //Make a move on the board for the second player
            board.MakeMove(new TTTMove(2, 1));

            //Check that the move was made correctly
            Assert.AreEqual(2, board.GetCell(2, 1));
        }
Esempio n. 2
0
        public void DuplicateTest()
        {
            //Create a new board and make a move in it
            TTTBoard boardA = new TTTBoard();

            boardA.MakeMove(new TTTMove(1, 1));

            //Duplicate the board and store it in a new board instance
            TTTBoard boardB = (TTTBoard)boardA.Duplicate();

            //Ensure the move made before duplication is present in both boards
            Assert.AreEqual(1, boardA.GetCell(1, 1));
            Assert.AreEqual(1, boardB.GetCell(1, 1));

            //These two board instances should share no memory, lets prove it by making moves in each of them and checking the other
            boardA.MakeMove(new TTTMove(2, 0));
            Assert.AreEqual(2, boardA.GetCell(2, 0));
            Assert.AreEqual(0, boardB.GetCell(2, 0));

            boardB.MakeMove(new TTTMove(1, 2));
            Assert.AreEqual(0, boardA.GetCell(1, 2));
            Assert.AreEqual(2, boardB.GetCell(1, 2));
        }
Esempio n. 3
0
        public void CreateBoardTest()
        {
            TTTBoard board = new TTTBoard();

            //Check that the current player is player 1
            Assert.AreEqual(1, board.CurrentPlayer);

            //Ensure that the created board is empty
            for (int y = 0; y < board.Height; y++)
            {
                for (int x = 0; x < board.Width; x++)
                {
                    Assert.AreEqual(0, board.GetCell(x, y));
                }
            }

            //Ensure that the winner value is - 1
            Assert.AreEqual(-1, board.Winner);
        }