AutocompleteTests.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Terminal.Gui;
  7. using Xunit;
  8. namespace UnitTests {
  9. public class AutocompleteTests {
  10. [Fact][AutoInitShutdown]
  11. public void Test_GenerateSuggestions_Simple()
  12. {
  13. var ac = new Autocomplete ();
  14. ac.AllSuggestions = new List<string> { "fish","const","Cobble"};
  15. var tv = new TextView ();
  16. tv.InsertText ("co");
  17. ac.GenerateSuggestions (tv);
  18. Assert.Equal (2, ac.Suggestions.Count);
  19. Assert.Equal ("const", ac.Suggestions[0]);
  20. Assert.Equal ("Cobble", ac.Suggestions[1]);
  21. }
  22. [Fact]
  23. [AutoInitShutdown]
  24. public void TestSettingColorSchemeOnAutocomplete ()
  25. {
  26. var tv = new TextView ();
  27. // to begin with we should be using the default menu color scheme
  28. Assert.Same (Colors.Menu, tv.Autocomplete.ColorScheme);
  29. // allocate a new custom scheme
  30. tv.Autocomplete.ColorScheme = new ColorScheme () {
  31. Normal = Application.Driver.MakeAttribute (Color.Black, Color.Blue),
  32. Focus = Application.Driver.MakeAttribute (Color.Black, Color.Cyan),
  33. };
  34. // should be seperate instance
  35. Assert.NotSame (Colors.Menu, tv.Autocomplete.ColorScheme);
  36. // with the values we set on it
  37. Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Normal.Foreground);
  38. Assert.Equal (Color.Blue, tv.Autocomplete.ColorScheme.Normal.Background);
  39. Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Focus.Foreground);
  40. Assert.Equal (Color.Cyan, tv.Autocomplete.ColorScheme.Focus.Background);
  41. }
  42. }
  43. }