AutocompleteTests.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnitTests;
  2. using Xunit.Abstractions;
  3. namespace UnitTests_Parallelizable.TextTests;
  4. /// <summary>
  5. /// Pure unit tests for Autocomplete functionality that don't require Application or Driver.
  6. /// Integration tests for Autocomplete (popup behavior, rendering) remain in UnitTests.
  7. /// </summary>
  8. public class AutocompleteTests (ITestOutputHelper output) : FakeDriverBase
  9. {
  10. private readonly ITestOutputHelper _output = output;
  11. [Fact]
  12. public void Test_GenerateSuggestions_Simple ()
  13. {
  14. var ac = new TextViewAutocomplete ();
  15. ((SingleWordSuggestionGenerator)ac.SuggestionGenerator).AllSuggestions =
  16. new () { "fish", "const", "Cobble" };
  17. var tv = new TextView ();
  18. tv.InsertText ("co");
  19. ac.HostControl = tv;
  20. ac.GenerateSuggestions (
  21. new (
  22. Cell.ToCellList (tv.Text),
  23. 2
  24. )
  25. );
  26. Assert.Equal (2, ac.Suggestions.Count);
  27. Assert.Equal ("const", ac.Suggestions [0].Title);
  28. Assert.Equal ("Cobble", ac.Suggestions [1].Title);
  29. }
  30. }