Example #1
0
        public void returns_expected_system_commands()
        {
            var sut = SystemCommandRegistry.CreateAndInitialize();

            var result = sut
                         .GetAll()
                         .Select(x => x.CommandName)
                         .ToArray();

            var expected = new[]
            {
                "help",
                "list"
            };

            Assert.Equal(expected, result);
        }
Example #2
0
        public CleeEngine(ICommandRegistry commandRegistry, ICommandFactory commandFactory,
                          IArgumentMapper argumentMapper, ICommandExecutor commandExecutor)
        {
            _registry        = commandRegistry;
            _commandFactory  = commandFactory;
            _mapper          = argumentMapper;
            _commandExecutor = commandExecutor;

            _systemRegistry = SystemCommandRegistry.CreateAndInitialize(); // this should be removed from the constructor!

            _systemCommandFactory = new SystemCommandFactory();
            _systemCommandFactory.RegisterInstance <ICommandRegistry>(_registry);
            _systemCommandFactory.RegisterInstance <ICommandFactory>(_commandFactory);
            _systemCommandFactory.RegisterInstance <IArgumentMapper>(_mapper);
            _systemCommandFactory.RegisterInstance <ICommandExecutor>(_commandExecutor);
            _systemCommandFactory.RegisterInstance <SystemCommandRegistry>(_systemRegistry);
            _systemCommandFactory.RegisterFactoryMethod <IOutputWriter>(() => _outputWriter);
            _systemCommandFactory.RegisterInstance(_settings);

            _history          = new LinkedList <HistoryEntry>();
            _outputWriter     = new DefaultOutputWriter();
            _exitCodeAssigner = exitCode => Environment.ExitCode = exitCode;
        }