public void GameEngineShouldPrintMessageWhenDimensionsOnBoardNotValid()
        {
            Mock<IRenderer> mockedRenderer = new Mock<IRenderer>();
            var mockedInput = new Mock<IInputProvider>();
            mockedRenderer.Setup(x => x.PrintMessage(It.IsAny<string>())).Verifiable();

            var players = new List<IPlayer>()
            {
                new Player("king"),
                new Player("pawn"),
                };
            var board = new Board(10, 10);
            var gameEngine = new KingSurvivalEngine(
                mockedRenderer.Object,
                mockedInput.Object,
                board,
                new WinningConditions(),
                players,
                new BoardMemory(),
                new CommandContext(new BoardMemory(), board, new Player("king")),
                new CommandFactory());

            gameEngine.InitializeGame();
            mockedRenderer.Verify(x => x.PrintMessage(It.Is<string>(y => y.Contains("board"))));
        }
Пример #2
0
 static void Main(string[] args)
 {
     IRenderer renderer = new ConsoleRenderer();
     renderer.RenderMainMenu();
     IInputProvider provider = new ConsoleInputProvider();
     IWinningConditions winningConditions=new WinningConditions();
     IBoard board=new Board();
     IChessEngine chessEngine = new KingSurvivalEngine(renderer, provider,board,winningConditions);
     chessEngine.Initialize();
     chessEngine.Start();
     //TODO:add main menu
 }
Пример #3
0
        public void Start(IRenderer renderer, IInputProvider provider)
        {
            renderer.RenderMainMenu();
            IWinningConditions winningConditions = new WinningConditions();
            var players = new List<IPlayer>();
            var kingPlayer = new Player("king");
            var pawnPlayer = new Player("pawn");
            players.Add(kingPlayer);
            players.Add(pawnPlayer);

            var board = new Board.Board();

            var engine = new KingSurvivalEngine(renderer, provider, board, winningConditions, players);
            engine.InitializeGame().StartGame();
        }
Пример #4
0
 /// <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 GameEngineShouldInitializeProperly()
        {
            Mock<IRenderer> mockedRenderer = new Mock<IRenderer>();
            var mockedInput = new Mock<IInputProvider>();
            mockedRenderer.Setup(x => x.PrintMessage(It.IsAny<string>())).Verifiable();

            var players = new List<IPlayer>()
            {
                new Player("king"),
                new Player("pawn"),
               };
            var gameEngine = new KingSurvivalEngine(
                mockedRenderer.Object,
                mockedInput.Object,
                new Board(),
                new WinningConditions(),
                players,
                new BoardMemory(),
                new CommandContext(new BoardMemory(), new Board(), new Player("king")),
                new CommandFactory());
            gameEngine.InitializeGame();
        }
        public void GameEngineShouldStartTheGameAndPrintWhenKinWon()
        {
            Mock<IRenderer> mockedRenderer = new Mock<IRenderer>();
            var mockedInput = new Mock<IInputProvider>();
            mockedRenderer.Setup(x => x.PrintMessage(It.IsAny<string>())).Verifiable();

            var board = new Board(8, 8);

            IFigure kingFigure = new KingFigure("K");
            IPosition kingPosition = new Position(0, 2);

            board.AddFigure(kingFigure, kingPosition);
            PawnFigure pawnA = new PawnFigure(Constants.FirstPawnDisplaySign);
            board.AddFigure(pawnA, new Position(1, 2));

            PawnFigure pawnB = new PawnFigure(Constants.SecondPawnDisplaySign);
            board.AddFigure(pawnB, new Position(1, 4));

            PawnFigure pawnC = new PawnFigure(Constants.ThirdPawnDisplaySign);
            board.AddFigure(pawnC, new Position(1, 6));

            PawnFigure pawnD = new PawnFigure(Constants.FourthPawnDisplaySign);
            board.AddFigure(pawnD, new Position(1, 0));

            var kingPlayer = new Player("king");
            kingPlayer.AddFigure(new MoveableFigure(kingFigure));

            var pawnPlayer = new Player("pawn");
            kingPlayer.AddFigure(new MoveableFigure(pawnA));
            kingPlayer.AddFigure(new MoveableFigure(pawnB));
            kingPlayer.AddFigure(new MoveableFigure(pawnC));
            kingPlayer.AddFigure(new MoveableFigure(pawnD));
            var players = new List<IPlayer>()
            {
                               kingPlayer,
                               pawnPlayer
            };

            var gameEngine = new KingSurvivalEngine(
                mockedRenderer.Object,
                mockedInput.Object,
                board,
                new WinningConditions(),
                players,
                new BoardMemory(),
                new CommandContext(new BoardMemory(), board, new Player("king")),
                new CommandFactory());

            gameEngine.StartGame();
            mockedRenderer.Verify(x => x.PrintMessage(It.Is<string>(y => y.Contains("won"))));
        }