Example #1
0
        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);
        }
        private void CreateFigures()
        {
            KingFigure kingFigure = new KingFigure();
            this.Board.AddFigure(kingFigure, new Position(Constants.InitialKingRow, Constants.InitialKingColumn));

            PawnAFigure pawnA = new PawnAFigure();
            this.Board.AddFigure(pawnA, new Position(Constants.PawnAInitialRow, Constants.PawnAInitialCol));

            PawnBFigure pawnB = new PawnBFigure();
            this.Board.AddFigure(pawnB, new Position(Constants.PawnBInitialRow, Constants.PawnBInitialCol));

            PawnCFigure pawnC = new PawnCFigure();
            this.Board.AddFigure(pawnC, new Position(Constants.PawnCInitialRow, Constants.PawnCInitialCol));

            PawnDFigure pawnD = new PawnDFigure();
            this.Board.AddFigure(pawnD, new Position(Constants.PawnDInitialRow, Constants.PawnDInitialCol));

            this.kingPlayer.AddFigure(kingFigure);

            this.pawnPlayer.AddFigure(pawnA);
            this.pawnPlayer.AddFigure(pawnB);
            this.pawnPlayer.AddFigure(pawnC);
            this.pawnPlayer.AddFigure(pawnD);
        }