예제 #1
0
        public void Should_return_valid_completion_for_empty_line()
        {
            // Arrange
            AutoCompleteInput input = GetAutoCompleteInstance();

            // Act
            string text = input.ReadLine(Tab);

            // Assert
            text.Should().Be("World");

            // Act
            text = input.ReadLine(Tab, Tab);

            // Assert
            text.Should().Be("Angel");

            // Act
            text = input.ReadLine(Tab, Tab, Tab);

            // Assert
            text.Should().Be("Hello");

            // Act
            text = input.ReadLine(Tab, Tab, Tab, Tab);

            // Assert
            text.Should().Be("World");

            // Act
            text = input.ReadLine(Tab, Tab, Tab, Tab, ShiftTab);

            // Assert
            text.Should().Be("Hello");
        }
예제 #2
0
        public void Up_arrow_should_return_valid_entry()
        {
            // Arrange
            AutoCompleteInput input = GetAutoCompleteInstance();

            // Act
            string text = input.ReadLine(UpArrow, UpArrow, UpArrow);

            // Assert
            text.Should().Be("dotnet run");

            // Act
            text = input.ReadLine(UpArrow, UpArrow, UpArrow, UpArrow, UpArrow, Enter);

            // Assert
            text.Should().Be("dotnet run");
        }
예제 #3
0
        public void Up_then_down_arrow_should_return_last_history_entry()
        {
            // Arrange
            AutoCompleteInput input = GetAutoCompleteInstance();

            // Act
            string text = input.ReadLine(UpArrow, DownArrow, Enter);

            // Assert
            text.Should().Be("clear");

            // Act
            text = input.ReadLine(UpArrow, DownArrow, DownArrow, DownArrow, Enter);

            // Assert
            text.Should().Be("clear");
        }
예제 #4
0
        public void Nothing_should_happen_without_auto_complete_handler()
        {
            // Arrange
            AutoCompleteInput input = new AutoCompleteInput(_console);

            // Act
            string text = input.ReadLine(Tab, Enter);

            // Assert
            text.Should().BeEmpty();

            // Act
            text = input.ReadLine(Tab, Tab, Tab);

            // Assert
            text.Should().BeEmpty();
        }
예제 #5
0
        public void Should_clear_history()
        {
            // Arrange
            AutoCompleteInput input = GetAutoCompleteInstance();

            // Act
            string text = input.ReadLine(UpArrow, UpArrow, UpArrow, Enter);

            // Assert
            text.Should().Be("dotnet run");

            // Act
            input.History.Clear();
            text = input.ReadLine(UpArrow, UpArrow, UpArrow, UpArrow, UpArrow, Enter);

            // Assert
            text.Should().BeEmpty();
        }
예제 #6
0
        public void Up_arrow_then_escape_should_return_empty()
        {
            // Arrange
            AutoCompleteInput input = GetAutoCompleteInstance();

            // Act
            string text = input.ReadLine(UpArrow, Escape, DownArrow, Enter);

            // Assert
            text.Should().BeEmpty();
        }
예제 #7
0
        public void Should_return_valid_completion_for_W_Tab()
        {
            // Arrange
            AutoCompleteInput input = GetAutoCompleteInstance();

            // Act
            string text = input.ReadLine('W'.ToConsoleKeyInfo(), Tab);

            // Assert
            text.Should().Be("World");
        }
예제 #8
0
        public void Nothing_should_happen_when_no_completions_available()
        {
            // Arrange
            AutoCompleteInput input = GetAutoCompleteInstance();

            // Act
            string text = input.ReadLine('X'.ToConsoleKeyInfo(), Tab);

            // Assert
            text.Should().Be("X");
        }
예제 #9
0
        public void Custom_shortcut_should_work()
        {
            bool test = false;

            // Arrange
            AutoCompleteInput input = new AutoCompleteInput(_console, new HashSet <ShortcutDefinition>
            {
                new ShortcutDefinition(ConsoleKey.A, ConsoleModifiers.Control, () => { test = true; }),
                new ShortcutDefinition(ConsoleKey.B, ConsoleModifiers.Control, () => { test = true; }),
                new ShortcutDefinition(ConsoleKey.B, () => { test = true; }),
            })
            {
                AutoCompletionHandler = new TestAutoCompleteHandler()
            };

            // History should be disabled by default.
            test.Should().BeFalse();

            // Act
            string text = input.ReadLine(CtrlA);

            // Assert
            test.Should().BeTrue();
        }