private static async Task <string> InvokeAsync(
            string[] args,
            ISuggestionRegistration suggestionProvider)
        {
            var dispatcher  = new SuggestionDispatcher(suggestionProvider, new TestSuggestionStore());
            var testConsole = new TestConsole();
            await dispatcher.InvokeAsync(args, testConsole);

            return(testConsole.Out.ToString());
        }
Ejemplo n.º 2
0
        public async Task Register_command_will_not_add_duplicate_entry()
        {
            var provider   = new TestSuggestionRegistration();
            var dispatcher = new SuggestionDispatcher(provider);

            var args = CommandLineStringSplitter.Instance.Split($"register --command-path \"{_netExeFullPath}\" --suggestion-command \"net-suggestions complete\"").ToArray();

            await dispatcher.InvokeAsync(args);

            await dispatcher.InvokeAsync(args);

            provider.FindAllRegistrations().Should().HaveCount(1);
        }
Ejemplo n.º 3
0
        public async Task Register_command_adds_new_suggestion_entry()
        {
            var provider   = new TestSuggestionRegistration();
            var dispatcher = new SuggestionDispatcher(provider);

            var args = CommandLineStringSplitter.Instance.Split($"register --command-path \"{_netExeFullPath}\" --suggestion-command \"net-suggestions complete\"").ToArray();

            await dispatcher.InvokeAsync(args);

            Registration addedRegistration = provider.FindAllRegistrations().Single();

            addedRegistration.ExecutablePath.Should().Be(_netExeFullPath);
        }
        public async Task List_command_gets_all_executable_names()
        {
            var testSuggestionProvider = new TestSuggestionRegistration(
                new RegistrationPair(_dotnetExeFullPath, "dotnet complete"),
                new RegistrationPair(_himalayanBerryExeFullPath, "himalayan-berry spread"));

            var dispatcher  = new SuggestionDispatcher(testSuggestionProvider);
            var testConsole = new TestConsole();

            await dispatcher.InvokeAsync(new[] { "list" }, testConsole);

            testConsole.Out.ToString().Should().Be($"dotnet himalayan-berry{Environment.NewLine}");
        }
Ejemplo n.º 5
0
        public async Task When_command_suggestions_use_process_that_remains_open_it_returns_empty_string()
        {
            var provider   = new TestSuggestionRegistration(new Registration(CurrentExeFullPath()));
            var dispatcher = new SuggestionDispatcher(provider, new TestSuggestionStore());

            dispatcher.Timeout = TimeSpan.FromMilliseconds(1);
            var testConsole = new TestConsole();

            var args = CommandLineStringSplitter.Instance.Split($@"get -p 0 -e ""{_currentExeName}"" -- {_currentExeName} add").ToArray();

            await dispatcher.InvokeAsync(args, testConsole);

            testConsole.Out.ToString().Should().BeEmpty();
        }
        public async Task Register_command_adds_new_suggestion_entry()
        {
            var provider   = new TestSuggestionRegistration();
            var dispatcher = new SuggestionDispatcher(provider);

            var args = $"register --command-path \"{_netExeFullPath}\" --suggestion-command \"net-suggestions complete\"".Tokenize().ToArray();

            await dispatcher.InvokeAsync(args);

            RegistrationPair addedRegistration = provider.FindAllRegistrations().Single();

            addedRegistration.CommandPath.Should().Be(_netExeFullPath);
            addedRegistration.SuggestionCommand.Should().Be("net-suggestions complete");
        }
        public async Task When_command_suggestions_use_process_that_remains_open_it_returns_empty_string()
        {
            var provider   = new TestSuggestionRegistration(new RegistrationPair(CurrentExeFullPath(), $"{_currentExeName} {Assembly.GetExecutingAssembly().Location}"));
            var dispatcher = new SuggestionDispatcher(provider, new TestSuggestionStore());

            dispatcher.Timeout = TimeSpan.FromMilliseconds(1);
            var testConsole = new TestConsole();

            var args = $@"get -p 0 -e ""{_currentExeName}"" -- {_currentExeName} add".Tokenize().ToArray();

            await dispatcher.InvokeAsync(args, testConsole);

            testConsole.Out.ToString().Should().BeEmpty();
        }
Ejemplo n.º 8
0
        public async Task List_command_gets_all_executable_names()
        {
            string _kiwiFruitExeFullPath =
                RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                    ? @"C:\Program Files\kiwi-fruit.exe"
                    : "/bin/kiwi-fruit";

            var testSuggestionProvider = new TestSuggestionRegistration(
                new Registration(_dotnetFormatExeFullPath),
                new Registration(_kiwiFruitExeFullPath));

            var dispatcher  = new SuggestionDispatcher(testSuggestionProvider);
            var testConsole = new TestConsole();

            await dispatcher.InvokeAsync(new[] { "list" }, testConsole);

            testConsole.Out
            .ToString()
            .Should()
            .Be($"dotnet-format{Environment.NewLine}dotnet format{Environment.NewLine}kiwi-fruit{Environment.NewLine}");
        }