本文整理汇总了C#中Game.MakeNextMove方法的典型用法代码示例。如果您正苦于以下问题:C# Game.MakeNextMove方法的具体用法?C# Game.MakeNextMove怎么用?C# Game.MakeNextMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.MakeNextMove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GivenGameInitializes_WhenAPlayerTicksWinningCombination_ThenPlayer1ShouldWin
public void GivenGameInitializes_WhenAPlayerTicksWinningCombination_ThenPlayer1ShouldWin()
{
// Assign
var game = new Game(new BoardDisplayer());
game.InitializeBoard();
game.MakeNextMove(Player.Player1, 0);
game.MakeNextMove(Player.Player1, 1);
game.MakeNextMove(Player.Player1, 2);
// Act
var hasPlayerWon = game.HasPlayerWon(Player.Player1);
// Assert
Assert.IsTrue(hasPlayerWon);
}
示例2: GivenGameInitializes_WhenAPlayerNotWins_ThenShouldNotDisplayResult
public void GivenGameInitializes_WhenAPlayerNotWins_ThenShouldNotDisplayResult()
{
// Assign
var boardDisplayerMock = new Mock<IBoardDisplayer>();
var game = new Game(boardDisplayerMock.Object);
game.InitializeBoard();
game.MakeNextMove(Player.Player1, 0);
// Act
game.PlayAndCheck(Player.Player1);
// Assert
boardDisplayerMock.Verify(b => b.DisplayWinner(Player.Player1), Times.Never);
}
示例3: GivenGameInitializes_WhenPlayer1MakesAMove_ThenBoardShouldShowThis
public void GivenGameInitializes_WhenPlayer1MakesAMove_ThenBoardShouldShowThis()
{
// Assign
var game = new Game(new BoardDisplayer());
game.InitializeBoard();
var randomCell = new Random().Next(0, 8);
// Act
game.MakeNextMove(Player.Player1, randomCell);
// Assert
for (var i = 0; i < game.Board.Cells.Count; i++)
{
if (i == randomCell)
{
Assert.AreEqual(Player.Player1, game.Board.Cells[randomCell].Value);
continue;
}
Assert.IsFalse(game.Board.Cells[i].Value.HasValue);
}
}
示例4: GivenGameInitializes_WhenPlayersUseAllTheCells_ThenGameShouldFinish
public void GivenGameInitializes_WhenPlayersUseAllTheCells_ThenGameShouldFinish()
{
// Assign
var game = new Game(new BoardDisplayer());
game.InitializeBoard();
for (var i = 0; i < game.Board.Cells.Count; i++)
{
game.MakeNextMove(Player.Player1, i);
}
// Act
bool isFinished = game.IsGameFinished();
// Assert
Assert.IsTrue(isFinished);
}
示例5: GivenGameInitializes_WhenGameStarts_ThenPlayersShouldPickRandomCells
public void GivenGameInitializes_WhenGameStarts_ThenPlayersShouldPickRandomCells()
{
// Assign
var game = new Game(new BoardDisplayer());
game.InitializeBoard();
// Act
var player1CellIndex = game.GetNextRandomAvailableCellIndex();
game.MakeNextMove(Player.Player1, player1CellIndex);
var player2Cell = game.GetNextRandomAvailableCellIndex();
game.MakeNextMove(Player.Player2, player2Cell);
// Assert
Assert.AreNotEqual(player1CellIndex, player2Cell);
}