Пример #1
0
        public void QueueRestart_Execute_ReturnsNotFoundMessage()
        {
            var command = new RestartCommand(_console, LoggerMock.GetLogger <RestartCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _jobQueueService.Object)
            {
                Project = "Project 1",
                Number  = "2"
            };

            var resultMessage = command.Execute();

            Assert.Equal("Failed to restart queue 2. Make sure the project name and queue number are correct.", resultMessage);
        }
Пример #2
0
        public void QueueRestart_Execute_ReturnsSuccessMessage()
        {
            var command = new RestartCommand(_console, LoggerMock.GetLogger <RestartCommand>().Object, _projectService.Object, _jobDefinitionService.Object, _jobQueueService.Object)
            {
                Project = "Project 1",
                Number  = "1"
            };

            var resultMessage = command.Execute();

            Assert.StartsWith("Queue 1 has been restarted successfully", resultMessage);
        }
        public void CheckIfMethodRestartExecuteReturnsProperString()
        {
            IMatrixField           field      = FieldFactory.Instance.GetField(5);
            IScoreboard            scoreboard = new ScoreboardProxy();
            IRandomNumberGenerator random     = new RandomNumberGenerator();
            IGameEngine            gameEngine = new GameFifteenEngine(field, scoreboard, random);

            RestartCommand restartCommand = new RestartCommand(gameEngine);

            string result = restartCommand.Execute();

            Assert.IsInstanceOfType(result, typeof(String));
        }
Пример #4
0
        public void RestartCommand_FormsCorrectApplicationRequest_WhenApplicationRunsUnderNetCoreAndSettingsPickedFromEnvironment()
        {
            IApplicationClient applicationClient = Substitute.For <IApplicationClient>();
            var environmentSettings = new EnvironmentSettings {
                Login      = "******",
                Password   = "******",
                IsNetCore  = true,
                Maintainer = "Test",
                Uri        = "http://test.domain.com"
            };
            RestartCommand restartCommand = new RestartCommand(applicationClient, environmentSettings);
            var            options        = Substitute.For <RestartOptions>();

            restartCommand.Execute(options);
            applicationClient.Received(1).ExecutePostRequest(
                environmentSettings.Uri + "/ServiceModel/AppInstallerService.svc/RestartApp",
                "{}", Timeout.Infinite);
        }
        /// <summary>
        /// Process the game.
        /// </summary>
        /// <param name="playBoard">Current play board value.</param>
        /// <param name="playerMoves">Current player moves.</param>
        public void ProcessGame(ref char[,] playBoard, ref int playerMoves)
        {
            byte rowLenght = (byte)playBoard.GetLength(0);
            byte columnLenght = (byte)playBoard.GetLength(1);
            Board boardGenerator = new Board(rowLenght, columnLenght);

            ScoreBoardFormatter formatter = new ScoreBoardFormatter();

            // ILogger fileLogger = new FileLogger("scorebord.txt", formatter);
            ILogger consoleLogger = new ConsoleLogger(formatter);
            ScoreBoard scoreBoard = new ScoreBoard(consoleLogger);

            var printer = PrintingManager.Instance;

            switch (this.currentCommand)
            {
                case "RESTART":
                    IInputCommand restart = new RestartCommand(boardGenerator, printer);
                    restart.Execute(ref playBoard, ref playerMoves);
                    break;

                case "TOP":
                    IInputCommand topscoreBoard = new TopCommand(scoreBoard, this.topPlayers);
                    topscoreBoard.Execute(ref playBoard, ref playerMoves);
                    break;

                case "EXIT":
                    break;

                default:
                    InputCommandValidator validator = new InputCommandValidator();
                    if (validator.IsValidInputCommand(this.currentCommand))
                    {
                        IInputCommand play = new PlayCommand(this.currentCommand, this.topPlayers, scoreBoard, boardGenerator, printer);
                        play.Execute(ref playBoard, ref playerMoves);
                        break;
                    }

                    Console.WriteLine("Wrong input ! Try Again ! ");
                    break;
            }
        }