示例#1
0
 /// <summary>
 /// Creates a new <see cref="FourInARowGame"/>.
 /// </summary>
 /// <param name="playerOne">Name of player one.</param>
 /// <param name="playerTwo">Name of player two.</param>
 /// <param name="boardSize">The <see cref="BoardSize"/>.</param>
 public FourInARowGame(string playerOneName, string playerTwoName, BoardSize boardSize)
 {
     PlayerOne       = new Player(playerOneName, BoardSlotValue.P1);
     PlayerTwo       = new Player(playerTwoName, BoardSlotValue.P2);
     _boardGrid      = new BoardGrid(boardSize);
     _playerSwitcher = new PlayerSwitcher(new [] { PlayerOne, PlayerTwo });
 }
        public void Can_detect_draw(IBoardGrid boardGrid, WinState expectedWinState)
        {
            var actualWinState = boardGrid.GetWinState();

            Assert.False(boardGrid.HasWinner());
            Assert.Null(actualWinState.Winner);

            Assert.Equal(expectedWinState.Method, actualWinState.Method);
            Assert.Equal(expectedWinState.HasWinner, actualWinState.HasWinner);
            Assert.Equal(expectedWinState.Winner, actualWinState.Winner);
        }
        public void Can_detect_winner(string useCase, IBoardGrid boardGrid, WinState expectedWinState)
        {
            var actualWinState = boardGrid.GetWinState();

            Assert.True(boardGrid.HasWinner());
            Assert.NotNull(actualWinState.Winner);

            Assert.Equal(expectedWinState.Method, actualWinState.Method);
            Assert.Equal(expectedWinState.HasWinner, actualWinState.HasWinner);
            Assert.Equal(expectedWinState.Winner, actualWinState.Winner);
        }
 public override WinStateCalculatorResult Calculate(IBoardGrid boardGrid)
 => CalculateWinStateCalculatorResultForBoardSlotDictionary(
     boardSlotDictionary: boardGrid.GetBoardSlotColumns(),
     orderFunction: boardSlots => boardSlots.OrderBy(slot => slot.Position.Row)
     )
 ;
 public override WinStateCalculatorResult Calculate(IBoardGrid boardGrid)
 => NoWinnerResult();
 /// <inhertidocs/>
 public abstract WinStateCalculatorResult Calculate(IBoardGrid boardGrid);
 public void Can_detect_when_a_column_is_full(IBoardGrid boardGrid, int columnIndex, bool expected)
 => Assert.Equal(expected, boardGrid.IsColumnFull(columnIndex));
 public override WinStateCalculatorResult Calculate(IBoardGrid boardGrid)
 => CalculateWinStateCalculatorResultForBoardSlotDictionary(
     boardSlotDictionary: boardGrid.GetBoardSlotDiagonalTopToBottomLines()
     )
 ;