public void CheckIfAnExceptionIsThrownWhenTheCommandIsThreeSymbolsLongButStillNotCorrect() { var player = new Player("Serafim"); var king = new KingFigure(); player.AddFigure(king); var board = new Board(); var position = new Position(Constants.InitialKingRow, Constants.InitialKingColumn); board.AddFigure(king, position); var commandFactory = new CommandFactory(); var commandContext = new CommandContext(new BoardMemory(), board, player); player.ExecuteCommand(commandContext, "aaa"); }
public void CheckIfAnExceptionIsThrownWhenTheCommandIsNotExactlyThreeSymbolsAndThePlayerIsPawn() { var player = new Player("Serafim"); var pawn = new PawnAFigure(); player.AddFigure(pawn); var board = new Board(); var position = new Position(Constants.InitialKingRow, Constants.InitialKingColumn); board.AddFigure(pawn, position); var commandFactory = new CommandFactory(); var commandContext = new CommandContext(new BoardMemory(), board, player); player.ExecuteCommand(commandContext, "aaaa"); }
/// <summary> /// Method for starting a game /// </summary> /// <param name="renderer">The renderer on which the info is going to be rendered</param> /// <param name="provider">The input provider that provides information</param> public void Start(IRenderer renderer, IInputProvider provider) { renderer.RenderMainMenu(); IWinningConditions winningConditions = new WinningConditions(); var players = new List<IPlayer>(); var kingPlayer = new Player(provider.GetPlayerName()); var pawnPlayer = new Player(provider.GetPlayerName()); players.Add(kingPlayer); players.Add(pawnPlayer); var board = new Board.Board(); var memory = new BoardMemory(); var context = new CommandContext(memory, board, players[0]); var commandFactory = new CommandFactory(); var engine = new KingSurvivalEngine(renderer, provider, board, winningConditions, players, memory, context, commandFactory); engine.InitializeGame().StartGame(); }
public void CheckIfTheKdlDirectionThrowsWhenThePositionIsNotValid() { var player = new Player("Serafim"); var king = new KingFigure(); player.AddFigure(king); var board = new Board(); var position = new Position(Constants.InitialKingRow, Constants.InitialKingColumn); board.AddFigure(king, position); var commandContext = new CommandContext(new BoardMemory(), board, player); player.ExecuteCommand(commandContext, "kdl"); }
public void CheckIfTheMoveMethodSetNewPositionsCorrectlywithTheDdrCommand() { var player = new Player("Serafim"); var pawnA = new PawnAFigure(); player.AddFigure(pawnA); var pawnB = new PawnBFigure(); player.AddFigure(pawnB); var pawnC = new PawnCFigure(); player.AddFigure(pawnC); var pawnD = new PawnDFigure(); player.AddFigure(pawnD); var board = new Board(); var position = new Position(Constants.PawnDInitialRow, Constants.PawnDInitialCol); board.AddFigure(pawnA, position); board.AddFigure(pawnB, position); board.AddFigure(pawnC, position); board.AddFigure(pawnD, position); var commandFactory = new CommandFactory(); var playerCommand = commandFactory.CreatePlayerCommand("ddr"); var commandContext = new CommandContext(new BoardMemory(), board, player); player.ExecuteCommand(commandContext, "ddr"); var actualPosition = board.GetFigurePosition(pawnD); var expectedPosition = new Position(1, 7); Assert.AreEqual(expectedPosition.Row, actualPosition.Row); Assert.AreEqual(expectedPosition.Col, actualPosition.Col); }
public void CheckIfTheMoveMethodSetNewPositionsCorrectlywithTheAdrCommand() { var player = new Player("Serafim"); var pawn = new PawnAFigure(); player.AddFigure(pawn); var board = new Board(); var position = new Position(Constants.PawnAInitialRow, Constants.PawnAInitialCol); board.AddFigure(pawn, position); var commandFactory = new CommandFactory(); var commandContext = new CommandContext(new BoardMemory(), board, player); player.ExecuteCommand(commandContext, "adr"); var actualPosition = board.GetFigurePosition(pawn); var expectedPosition = new Position(1, 1); Assert.AreEqual(expectedPosition.Row, actualPosition.Row); Assert.AreEqual(expectedPosition.Col, actualPosition.Col); }
public void CheckIfTheMoveMethodSetNewPositionsCorrectlywithTheAdlCommand() { var player = new Player("Serafim"); var pawn = new PawnAFigure(); player.AddFigure(pawn); var board = new Board(); var position = new Position(0, 0); board.AddFigure(pawn, position); var commandFactory = new CommandFactory(); var commandContext = new CommandContext(new BoardMemory(), board, player); player.ExecuteCommand(commandContext, "adl"); }
public void CheckIfTheKurDirectionIsCorrectlyChanged() { var player = new Player("Serafim"); var king = new KingFigure(); player.AddFigure(king); var board = new Board(); var position = new Position(Constants.InitialKingRow, Constants.InitialKingColumn); board.AddFigure(king, position); var commandContext = new CommandContext(new BoardMemory(), board, player); player.ExecuteCommand(commandContext, "kur"); var actualPosition = board.GetFigurePosition(king); var expectedPosition = new Position(6, 4); Assert.AreEqual(expectedPosition.Row, actualPosition.Row); Assert.AreEqual(expectedPosition.Col, actualPosition.Col); }