예제 #1
0
        public void WhenExecuteCommandWithRegisteredParameters_CommandManager_ShouldShowList()
        {
            var path1 = "my.path1";
            var path2 = "my.path2";
            var name1 = "myname1";
            var name2 = "myname2";

            var registeredTemplates = new List <RegisteredTemplate>()
            {
                new RegisteredTemplate(path1, name1, null),
                new RegisteredTemplate(path2, name2, null)
            };
            var storedDataService = new StoredDataServiceMock()
            {
                TemplatesForReturn = registeredTemplates
            };
            var commandDefinition = new ShowTemplatesCommand(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 = registeredTemplates.ToDisplayList(
                k => $"{k.TemplateName} => {k.Description} located at {k.Path}",
                ShowTemplatesCommand.ListHeaderDisplay,
                ShowTemplatesCommand.ListFirstCharLine);
            var actual = _loggerServiceMock.Logs.First();

            Assert.Equal(expected, actual);
        }
예제 #2
0
        public void WhenExecuteCommandWithZeroRegisteredParameters_CommandManager_ShouldShowZeroMessage()
        {
            var storedDataService = new StoredDataServiceMock()
            {
                TemplatesForReturn = new List <RegisteredTemplate>()
            };
            var commandDefinition = new ShowTemplatesCommand(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 = ShowTemplatesCommand.ZeroRegisteredMessage;
            var actual   = _loggerServiceMock.Logs.First();

            Assert.Equal(expected, actual);
        }