private (Game game, GameState gameState) BuildGame(string boardString, Color turn, int?captureSequenceFrom = null) { var board = BoardPosition.FromString(boardString); var game = GameTestHelper.StartedMiniGame().WithTurn(turn).Build(); var gameState = GameState.FromStorage(game.Id, boardString, captureSequenceFrom); return(game, gameState); }
public void CantMoveOpponentsPieces() { var game = GameTestHelper.StartedMiniGame().WithTurn(Color.White).Build(); var gameState = GameState.InitialState(game.Id, game.Settings.BoardSize); Action doMove = () => DoMove(game, gameState, 4, 7); doMove.Should().Throw <ManualValidationException>($"You can only move {Color.White} pieces."); }
public void CantMoveWhenNotYourTurn() { var game = GameTestHelper.StartedMiniGame().WithTurn(Color.White).Build(); var gameState = GameState.InitialState(game.Id, game.Settings.BoardSize); Action doMove = () => DoMoveAs(game, gameState, 4, 7, Color.Black); doMove.Should().Throw <ManualValidationException>().WithMessage(Game.ERROR_NOT_YOUR_TURN); }
public void CantMoveOutsideTheBoard() { var game = GameTestHelper.StartedMiniGame().Build(); var gameState = GameState.InitialState(game.Id, game.Settings.BoardSize); Action toOutside = () => DoMove(game, gameState, 18, 20); Action fromOutside = () => DoMove(game, gameState, 20, 18); toOutside.Should().Throw <ManualValidationException>(GameState.ERROR_INVALID_SQUARES); fromOutside.Should().Throw <ManualValidationException>(GameState.ERROR_INVALID_SQUARES); }
public void DoMoveAndSwitchTurn() { // |_|4|_|4|_|4| // |4|_|4|_|4|_| // |_|.|_|.|_|.| // |.|_|.|_|.|_| // |_|5|_|5|_|5| // |5|_|5|_|5|_| var game = GameTestHelper.StartedMiniGame().Build(); var gameState = GameState.InitialState(game.Id, game.Settings.BoardSize); DoMove(game, gameState, 13, 11); gameState.Board.ToLongString(" ", "").Should().Be("444 444 000 050 055 555"); gameState.CaptureSequenceFrom.Should().BeNull(); game.Turn !.Player.Color.Should().Be(Color.Black); }