More tests

This commit is contained in:
Thomas
2023-04-01 08:11:12 +01:00
parent 86a2a2a956
commit a3b154749a

View File

@@ -104,7 +104,8 @@ namespace Terminal.Gui.ViewTests {
[Theory, AutoInitShutdown]
[InlineData("ffffffffffffffffffffffffff","ffffffffff")]
[InlineData("fffffffffff","ffffffffff")]
[InlineData("f234567890","f234567890")]
[InlineData("fisérables","fisérables")]
public void TestAutoAppendRendering_ShouldNotOverspill(string overspillUsing,string expectRender)
{
var tf = GetTextFieldsInViewSuggesting(overspillUsing);
@@ -144,6 +145,47 @@ namespace Terminal.Gui.ViewTests {
Assert.Equal("f",tf.Text.ToString());
}
[Fact, AutoInitShutdown]
public void TestAutoAppend_NoRender_WhenNoMatch()
{
var tf = GetTextFieldsInViewSuggesting("fish");
// f is typed and suggestion is "fish"
Application.Driver.SendKeys('f',ConsoleKey.F,false,false,false);
tf.Redraw(tf.Bounds);
TestHelpers.AssertDriverContentsAre("fish",output);
Assert.Equal("f",tf.Text.ToString());
// x is typed and suggestion should disapear
Application.Driver.SendKeys('x',ConsoleKey.F,false,false,false);
tf.Redraw(tf.Bounds);
TestHelpers.AssertDriverContentsAre("fx",output);
Assert.Equal("fx",tf.Text.ToString());
}
[Fact, AutoInitShutdown]
public void TestAutoAppend_NoRender_WhenCursorNotAtEnd()
{
var tf = GetTextFieldsInViewSuggesting("fish");
// f is typed and suggestion is "fish"
Application.Driver.SendKeys('f',ConsoleKey.F,false,false,false);
tf.Redraw(tf.Bounds);
TestHelpers.AssertDriverContentsAre("fish",output);
Assert.Equal("f",tf.Text.ToString());
// add a space then go back 1
Application.Driver.SendKeys(' ',ConsoleKey.Spacebar,false,false,false);
Application.Driver.SendKeys('<',ConsoleKey.LeftArrow,false,false,false);
tf.Redraw(tf.Bounds);
TestHelpers.AssertDriverContentsAre("f",output);
Assert.Equal("f ",tf.Text.ToString());
}
private TextField GetTextFieldsInViewSuggesting (params string[] suggestions)
{
var tf = GetTextFieldsInView();