Пример #1
0
        public void WhenFirstPlayerStartsInCorner_ThenDoMoveMustPutPieceInCenter()
        {
            ComputerPlayer target = new ComputerPlayer();
            var            board  = new Piece[3, 3];

            board[0, 0] = Piece.X; board[1, 0] = Piece.Empty; board[2, 0] = Piece.Empty;
            board[0, 1] = Piece.Empty; board[1, 1] = Piece.Empty; board[2, 1] = Piece.Empty;
            board[0, 2] = Piece.Empty; board[1, 2] = Piece.Empty; board[2, 2] = Piece.Empty;
            var boardState = new BoardState(null);

            boardState.Board = board;
            target.DoMove(Piece.O, boardState);
            Assert.AreEqual(Piece.O, boardState.Board[1, 1]);
        }
Пример #2
0
        public void WhenComputerPlayerHasPossibilityToWinInNextMove_ThenDoMoveMustMustSelectWinningMove()
        {
            ComputerPlayer target = new ComputerPlayer();
            var            board  = new Piece[3, 3];

            board[0, 0] = Piece.X; board[1, 0] = Piece.O; board[2, 0] = Piece.X;
            board[0, 1] = Piece.X; board[1, 1] = Piece.O; board[2, 1] = Piece.Empty;
            board[0, 2] = Piece.Empty; board[1, 2] = Piece.Empty; board[2, 2] = Piece.Empty;
            var boardState = new BoardState(null);

            boardState.Board = board;
            target.DoMove(Piece.O, boardState);
            Assert.AreEqual(Piece.O, boardState.Board[1, 2]);
        }
Пример #3
0
        public void WhenAllButOnePositionsAreFull_ThenDoMoveUsesLastPosition()
        {
            ComputerPlayer target = new ComputerPlayer();
            var            board  = new Piece[3, 3];

            board[0, 0] = Piece.O; board[1, 0] = Piece.X; board[2, 0] = Piece.O;
            board[0, 1] = Piece.O; board[1, 1] = Piece.O; board[2, 1] = Piece.X;
            board[0, 2] = Piece.X; board[1, 2] = Piece.X; board[2, 2] = Piece.Empty;
            var boardState = new BoardState(null);

            boardState.Board = board;
            target.DoMove(Piece.O, boardState);
            Assert.AreEqual(Piece.O, boardState.Board[2, 2]);
        }