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"); }
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"); }
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"); }
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(); }
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(); }
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(); }
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"); }
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"); }
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(); }