Exemple #1
0
        public void WhenExecuteCommandWithoutQuestion_CommandManager_ShouldThrowException()
        {
            var storedDataService = new StoredDataServiceMock();

            var consoleServiceMock = new ConsoleServiceMock();

            var commandDefinition = new ConfirmCommand();

            commandDefinition.ConsoleService = consoleServiceMock;
            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);

            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName());

            Assert.Throws <InvalidParamsException>(() =>
            {
                instance.ExecuteInputRequest(inputRequest, new List <string>()
                {
                });
            });
        }
Exemple #2
0
        public void WhenExecuteCommandText_CommandManager_ShouldLogText()
        {
            var question           = "myQuestion";
            var response           = "invalidYes";
            var storedDataService  = new StoredDataServiceMock();
            var consoleServiceMock = new ConsoleServiceMock();
            var commandDefinition  = new ConfirmCommand();
            var instance           = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

            instance.RegisterCommand(commandDefinition);
            instance.OnLog += Instance_OnLog;
            var inputRequest = new InputRequest(
                commandDefinition.GetInvocationCommandName(),
                commandDefinition.CommandQuestionParameter.GetInvokeName(),
                question);

            Assert.Throws <NotConfirmedException>(() =>
            {
                instance.ExecuteInputRequest(inputRequest, new List <string>()
                {
                    response
                });
            });
        }