示例#1
0
        private static void ValidateCompletion(
            ConsoleLineInput input,
            int?cursorIndex,
            bool reverseOrder,
            bool lastOperationWasCompletion,
            string expectedResult)
        {
            var console = input.ConsoleOutput;

            if (cursorIndex.HasValue)
            {
                input.MoveCursorToStart();
                input.MoveCursorForward(cursorIndex.Value).Should().BeTrue();
            }

            if (reverseOrder)
            {
                input.ReplaceCurrentTokenWithPreviousCompletion(lastOperationWasCompletion);
            }
            else
            {
                input.ReplaceCurrentTokenWithNextCompletion(lastOperationWasCompletion);
            }

            input.Contents.Should().Be(expectedResult);
            GetContents((SimulatedConsoleOutput)console).TrimEnd().Should().Be(expectedResult);
            console.CursorTop.Should().Be(0);
            console.CursorLeft.Should().Be(expectedResult.Length);
        }
示例#2
0
        private static ConsoleReader CreateReader(IEnumerable <ConsoleKeyInfo> keyStream, ConsoleCompletionHandler completionHandler = null)
        {
            var consoleOutput = new SimulatedConsoleOutput();
            var consoleInput  = new SimulatedConsoleInput(keyStream);
            var input         = new ConsoleLineInput(consoleOutput, new ConsoleInputBuffer(), new ConsoleHistory(), completionHandler);

            return(new ConsoleReader(input, consoleInput, consoleOutput, null));
        }
        private static ConsoleReader CreateReader(IEnumerable <ConsoleKeyInfo> keyStream, ITokenCompleter tokenCompleter = null)
        {
            var consoleOutput = new SimulatedConsoleOutput();
            var consoleInput  = new SimulatedConsoleInput(keyStream);
            var input         = new ConsoleLineInput(consoleOutput, new ConsoleInputBuffer(), new ConsoleHistory())
            {
                TokenCompleter = tokenCompleter
            };

            return(new ConsoleReader(input, consoleInput, consoleOutput, null));
        }
示例#4
0
        private ConsoleLineInput CreateInput(IConsoleOutput consoleOutput = null, ConsoleCompletionHandler completionHandler = null)
        {
            consoleOutput = consoleOutput ?? Substitute.For <IConsoleOutput>();
            var buffer  = new ConsoleInputBuffer();
            var history = new ConsoleHistory();
            var input   = new ConsoleLineInput(consoleOutput, buffer, history, completionHandler);

            input.ConsoleOutput.Should().BeSameAs(consoleOutput);
            input.Buffer.Should().BeSameAs(buffer);
            input.History.Should().BeSameAs(history);
            input.CompletionHandler.Should().BeSameAs(completionHandler);
            input.InsertMode.Should().BeTrue();

            return(input);
        }