public void IsBombHandlerShouldHandleTheRequestIfTheCellIsABomb()
 {
     var testHandler = new IsBombHandler();
     var testBoard = new Board(new EasyBoardSettings(), new List<IBoardObserver>());
     testHandler.SetSuccessor(new IsAlreadyShownHandler());
     testBoard.Cells[0, 0] = new CellContext();
     testBoard.Cells[0, 0].Content = new Bomb();
     testHandler.HandleRequest(row: 0, col: 0, board: testBoard);
     Assert.AreEqual(BoardState.Closed, testBoard.BoardState);
 }
 public void IsBombHandlerShouldPassTheRequestToItsSuccessorIfTheContentIsEmpty()
 {
     var testHandler = new IsBombHandler();
     var testBoard = new Board(new EasyBoardSettings(), new List<IBoardObserver>());
     testHandler.SetSuccessor(new IsAlreadyShownHandler());
     testBoard.Cells[0, 0] = new CellContext();
     testBoard.Cells[0, 0].Content = new EmptyContent();
     testBoard.Cells[0, 0].State = CellState.Revealed;
     testHandler.HandleRequest(row: 0, col: 0, board: testBoard);
     Assert.AreEqual(BoardState.Pending, testBoard.BoardState);
 }
        /// <summary>
        /// The concrete implementation of the common method Execute setting up all handlers and successors
        /// and calling the first fro their chain
        /// </summary>
        /// <param name="command">The command to be executed</param>
        public void Execute(string command)
        {
            var isValidPlayCommandHandler = new IsValidPlayCommandHandler();
            var isInsideBoardHandler = new IsInsideBoardHandler();
            var isAlreadyShownHandler = new IsAlreadyShownHandler();
            var isBombHandler = new IsBombHandler();
            var revealCellHandler = new RevealCellHandler();

            isValidPlayCommandHandler.SetSuccessor(isInsideBoardHandler);
            isInsideBoardHandler.SetSuccessor(isAlreadyShownHandler);
            isAlreadyShownHandler.SetSuccessor(isBombHandler);
            isBombHandler.SetSuccessor(revealCellHandler);

            isValidPlayCommandHandler.HandleRequest(command, this.board);
        }