public void ShouldFinish() { RandomPlayer one = new RandomPlayer(); RandomPlayer two = new RandomPlayer(); GomokuEngine game = new GomokuEngine(one, two); // Random behavior can't really be tested. // "test" verifies that a game will eventually end with two RandomPlayers. while (!game.IsOver) { Result result; do { // Get the current (random) player and generate a random // stone from the existing game moves. Stone stone = game.Current.GenerateMove(game.Stones); result = game.Place(stone); Console.WriteLine(result); } while(!result.IsSuccess); } }
public void ShouldSwapAfterSuccessfulStonePlacement() { // The GomokuEngine tracks the state of the game including whose turn it is. // Check that the GomokuEngine swaps the current player // after a stone has been successfully placed. // Get the current player. IPlayer previous = game.Current; // Rely upon the GomokuEngine's `IsBlacksTurn` property to determine the current player's stone color. bool isBlack = game.IsBlacksTurn; // Create a new stone for the uppermost left hand spot on the board. Stone stone = new Stone(0, 0, isBlack); // Place the stone and capture the result into a variable. Result result = game.Place(stone); // Check that the stone was successfully placed. Assert.True(result.IsSuccess); // Check that the current player has changed. IPlayer next = game.Current; Assert.AreNotEqual(previous, next); // Check that it's no longer black's turn. Assert.False(game.IsBlacksTurn); }