コード例 #1
0
        public void IsValidMove_WhenMoveExceedsBoard_ReturnsFalse(int size, int row, int column)
        {
            bool actual = systemUnderTest.IsValidMove(new Move(Player.X, row, column), GameState.NewGameXMove,
                                                      new GameBoardMark[size, size]);

            Assert.IsFalse(actual);
        }
コード例 #2
0
        public void MakeMove_WhenInvoked_MakesMove()
        {
            InvokeMakeMove();

            Received.InOrder(() =>
            {
                moveValidatorMock.IsValidMove(move, Arg.Any <GameState>(), board);
                gameBoardMock.PlaceMarker(move);
                gameBoardAnalyzerMock.AnalyzeGameBoard(board);
            });
        }
コード例 #3
0
 /// <summary>
 /// Handle chess piece move if valid
 /// </summary>
 /// <param name="newX">X coordinate to move to</param>
 /// <param name="newY">Y coordinate to move to</param>
 /// <remarks>
 /// Would ideally have separate unit tests for this but code is covered in current PawnTests
 /// </remarks>
 public void Move(int newX, int newY)
 {
     if (_validator.IsValidMove(newX, newY))
     {
         _chessPiece.XCoordinate = newX;
         _chessPiece.YCoordinate = newY;
     }
 }
コード例 #4
0
        public bool MakeMove(Move move)
        {
            if (!moveValidator.IsValidMove(move, GameState, GameBoard))
            {
                return(false);
            }

            gameBoard.PlaceMarker(move);

            GameBoardState gameBoardState = gameBoardAnalyzer.AnalyzeGameBoard(GameBoard);

            UpdateGameState(gameBoardState);

            return(true);
        }