Esempio n. 1
0
 public void Test_ExecuteCommandWithValidParam()
 {
     var executor = new CommandExecutor();
     IUIManager consoleUIManager = new UIManager(new ConsoleRenderer(), new ConsoleReader());
     MinesweeperGame game = new MinesweeperGameEasy(consoleUIManager);
     CommandParser commandParser = new CommandParser(game);
     ICommand restartCommand = commandParser.ParseCommand("restart");
     ICommand topCommand = commandParser.ParseCommand("top");
     var executedRestart = executor.ExecuteCommand(restartCommand);
     var executedTop = executor.ExecuteCommand(topCommand);
     Assert.ReferenceEquals(executedRestart, executedTop);
 }
Esempio n. 2
0
        /// <summary>
        /// Runs the main game loop - accepts user input, parses the input and executes the command.
        /// </summary>
        public void Run()
        {
            // IUIManager bridged with IRenderer and IUserInputReader
            IUIManager consoleUIManager = new UIManager(new ConsoleRenderer(), new ConsoleReader());

            MinesweeperGame game = new MinesweeperGameEasy(consoleUIManager);
            CommandParser commandParser = new CommandParser(game);
            CommandExecutor cmdExecutor = new CommandExecutor();
          
            // Start game loop
            bool gameRunning = true;
            while (gameRunning)
            {
                string input = consoleUIManager.ReadInput();

                ICommand command = commandParser.ParseCommand(input);

                gameRunning = cmdExecutor.ExecuteCommand(command);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Runs the main game loop - accepts user input, parses the input and executes the command.
        /// </summary>
        public void Run()
        {
            // IUIManager bridged with IRenderer and IUserInputReader
            IUIManager consoleUIManager = new UIManager(new ConsoleRenderer(), new ConsoleReader());

            MinesweeperGame game          = new MinesweeperGameEasy(consoleUIManager);
            CommandParser   commandParser = new CommandParser(game);
            CommandExecutor cmdExecutor   = new CommandExecutor();

            // Start game loop
            bool gameRunning = true;

            while (gameRunning)
            {
                string input = consoleUIManager.ReadInput();

                ICommand command = commandParser.ParseCommand(input);

                gameRunning = cmdExecutor.ExecuteCommand(command);
            }
        }