Exemple #1
0
        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);
        }
Exemple #2
0
        public void CheckIfTheMoveMethodSetNewPositionsCorrectlywithTheCdlCommand()
        {
            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 board    = new Board();
            var position = new Position(Constants.PawnCInitialRow, Constants.PawnCInitialCol);

            board.AddFigure(pawnA, position);
            board.AddFigure(pawnB, position);
            board.AddFigure(pawnC, position);

            var commandFactory = new CommandFactory();

            var commandContext = new CommandContext(new BoardMemory(), board, player);

            player.ExecuteCommand(commandContext, "cdl");

            var actualPosition   = board.GetFigurePosition(pawnC);
            var expectedPosition = new Position(1, 3);

            Assert.AreEqual(expectedPosition.Row, actualPosition.Row);
            Assert.AreEqual(expectedPosition.Col, actualPosition.Col);
        }
Exemple #3
0
        public void CheckIfTheMoveMethodThrowsCorrectlyIfTheCommandIsThreeSymbolsLongButStillNotCorrect()
        {
            var player = new Player("Serafim");

            var king = new PawnAFigure();

            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");
        }
Exemple #4
0
        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");
        }
Exemple #5
0
        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");
        }