Esempio n. 1
0
        public void WhenExecuteCommandWithZeroRegisteredParameters_CommandManager_ShouldShowZeroMessage()
        {
            var storedDataService = new StoredDataServiceMock()
            {
                ParametersWithValueForReturn = new List <string>()
            };
            var commandDefinition = new ShowParametersCommand(storedDataService);

            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

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

            instance.ExecuteInputRequest(inputRequest);

            var expected = ShowParametersCommand.ZeroRegisteredMessage;
            var actual   = _loggerServiceMock.Logs.First();

            Assert.Equal(expected, actual);
        }
Esempio n. 2
0
        public void WhenExecuteCommandWithRegisteredParameters_CommandManager_ShouldShowList()
        {
            var key1   = "my.pram1";
            var key2   = "my.pram2";
            var value1 = "my val 1";
            var value2 = "my val 2";

            var pair1 = $"{key1} => {value1}";
            var pair2 = $"{key2} => {value2}";

            var listed = new List <string>()
            {
                pair1, pair2
            };

            var storedDataService = new StoredDataServiceMock()
            {
                ParametersWithValueForReturn = listed
            };
            var commandDefinition = new ShowParametersCommand(storedDataService);

            var instance = new CommandManager(_loggerServiceMock, storedDataService, _cryptoServiceMock);

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

            instance.ExecuteInputRequest(inputRequest);

            var expected = listed.ToDisplayList(
                ShowParametersCommand.ParameterListHeaderDisplay,
                ShowParametersCommand.ParameterListFirstCharLine);
            var actual = _loggerServiceMock.Logs.First();

            Assert.Equal(expected, actual);
        }