Files
Terminal.Gui/UnitTests/AutocompleteTests.cs
BDisp 84f79b2326 Fixes #1445. Fixing more the Curses and WSL clipboard. (#1448)
* Fixes #1445. Fixing more the Curses and WSL clipboard.

* Fixing unit tests.

* Changing namespace.

* Fixes WSL2 clipboard unit test.

* Upgrades devcontainer with the MainLoop fix.

* Fixes pasting with no selection and with lines break.

* Prevents the event button click being fired after a button pressed with mouse move.

* Fixes the char [ not being processed.
2021-09-29 14:22:23 -07:00

58 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terminal.Gui;
using Xunit;
namespace Terminal.Gui.Core {
public class AutocompleteTests {
[Fact][AutoInitShutdown]
public void Test_GenerateSuggestions_Simple()
{
var ac = new Autocomplete ();
ac.AllSuggestions = new List<string> { "fish","const","Cobble"};
var tv = new TextView ();
tv.InsertText ("co");
ac.GenerateSuggestions (tv);
Assert.Equal (2, ac.Suggestions.Count);
Assert.Equal ("const", ac.Suggestions[0]);
Assert.Equal ("Cobble", ac.Suggestions[1]);
}
[Fact]
[AutoInitShutdown]
public void TestSettingColorSchemeOnAutocomplete ()
{
var tv = new TextView ();
// to begin with we should be using the default menu color scheme
Assert.Same (Colors.Menu, tv.Autocomplete.ColorScheme);
// allocate a new custom scheme
tv.Autocomplete.ColorScheme = new ColorScheme () {
Normal = Application.Driver.MakeAttribute (Color.Black, Color.Blue),
Focus = Application.Driver.MakeAttribute (Color.Black, Color.Cyan),
};
// should be seperate instance
Assert.NotSame (Colors.Menu, tv.Autocomplete.ColorScheme);
// with the values we set on it
Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Normal.Foreground);
Assert.Equal (Color.Blue, tv.Autocomplete.ColorScheme.Normal.Background);
Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Focus.Foreground);
Assert.Equal (Color.Cyan, tv.Autocomplete.ColorScheme.Focus.Background);
}
}
}