Пример #1
0
        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");
        }
Пример #2
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");
        }
Пример #3
0
        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");
        }
Пример #4
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);
        }
Пример #5
0
        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);
        }
Пример #6
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");
        }
Пример #7
0
        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);
        }