mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-10-31 00:59:26 +08:00 
			
		
		
		
	Added tests on backward direction of autocomplete
This commit is contained in:
		 nkochnev
					nkochnev
				
			
				
					committed by
					
						 Patrik Svensson
						Patrik Svensson
					
				
			
			
				
	
			
			
			 Patrik Svensson
						Patrik Svensson
					
				
			
						parent
						
							1082ac1efc
						
					
				
				
					commit
					088db165ed
				
			| @@ -61,6 +61,15 @@ public sealed class TestConsoleInput : IAnsiConsoleInput | ||||
|         _input.Enqueue(new ConsoleKeyInfo((char)input, input, false, false, false)); | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     /// Pushes the specified key to the input queue. | ||||
|     /// </summary> | ||||
|     /// <param name="consoleKeyInfo">The input.</param> | ||||
|     public void PushKey(ConsoleKeyInfo consoleKeyInfo) | ||||
|     { | ||||
|         _input.Enqueue(consoleKeyInfo); | ||||
|     } | ||||
|  | ||||
|     /// <inheritdoc/> | ||||
|     public bool IsKeyAvailable() | ||||
|     { | ||||
|   | ||||
| @@ -0,0 +1 @@ | ||||
| Favorite fruit? [Banana/Bandana/Orange]: Ban   Banana      Bandana       Banana | ||||
| @@ -154,6 +154,30 @@ public sealed class TextPromptTests | ||||
|         return Verifier.Verify(console.Output); | ||||
|     } | ||||
|  | ||||
|     [Fact] | ||||
|     [Expectation("AutoComplete_PreviousChoice")] | ||||
|     public Task Should_Auto_Complete_To_Previous_Choice_When_Pressing_ShiftTab_On_A_Match() | ||||
|     { | ||||
|         // Given | ||||
|         var console = new TestConsole(); | ||||
|         console.Input.PushText("Ban"); | ||||
|         console.Input.PushKey(ConsoleKey.Tab); | ||||
|         console.Input.PushKey(ConsoleKey.Tab); | ||||
|         var shiftTab = new ConsoleKeyInfo((char)ConsoleKey.Tab, ConsoleKey.Tab, true, false, false); | ||||
|         console.Input.PushKey(shiftTab); | ||||
|         console.Input.PushKey(ConsoleKey.Enter); | ||||
|  | ||||
|         // When | ||||
|         console.Prompt( | ||||
|             new TextPrompt<string>("Favorite fruit?") | ||||
|                 .AddChoice("Banana") | ||||
|                 .AddChoice("Bandana") | ||||
|                 .AddChoice("Orange")); | ||||
|  | ||||
|         // Then | ||||
|         return Verifier.Verify(console.Output); | ||||
|     } | ||||
|  | ||||
|     [Fact] | ||||
|     [Expectation("CustomValidation")] | ||||
|     public Task Should_Return_Error_If_Custom_Validation_Fails() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user