mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Fixes #4282 - Migrate tests from UnitTests to UnitTests.Parallelizable (67 tests migrated + comprehensive documentation) (#4293)
* Initial plan * Add 31 parallelizable LineCanvas unit tests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add 4 parallelizable Ruler unit tests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Complete Category A migration - 35 tests migrated Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove duplicate tests from UnitTests after migration to Parallelizable Co-authored-by: tig <585482+tig@users.noreply.github.com> * Migrate 6 pure unit tests from ColorPicker and DatePicker to Parallelizable Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix duplicate test names between UnitTests and Parallelizable Co-authored-by: tig <585482+tig@users.noreply.github.com> * Migrate 11 Label tests to Parallelizable (52 tests total) Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix documentation: SetupFakeDriver tests CAN be parallelized Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add comprehensive parallelization rules to documentation Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update README and start migrating Button/CheckBox/RadioGroup tests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove duplicate Button tests from UnitTests Co-authored-by: tig <585482+tig@users.noreply.github.com> * Migrate 5 CheckBox unit tests to Parallelizable (27 with Theory expansion) Co-authored-by: tig <585482+tig@users.noreply.github.com> * Migrate 4 more CheckBox tests to Parallelizable (67 tests total, 9,478 passing) Co-authored-by: tig <585482+tig@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
@@ -5,146 +5,6 @@ namespace Terminal.Gui.ViewsTests;
|
||||
|
||||
public class ButtonTests (ITestOutputHelper output)
|
||||
{
|
||||
// Test that Title and Text are the same
|
||||
[Fact]
|
||||
public void Text_Mirrors_Title ()
|
||||
{
|
||||
var view = new Button ();
|
||||
view.Title = "Hello";
|
||||
Assert.Equal ("Hello", view.Title);
|
||||
Assert.Equal ("Hello", view.TitleTextFormatter.Text);
|
||||
|
||||
Assert.Equal ("Hello", view.Text);
|
||||
Assert.Equal ($"{Glyphs.LeftBracket} Hello {Glyphs.RightBracket}", view.TextFormatter.Text);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Title_Mirrors_Text ()
|
||||
{
|
||||
var view = new Button ();
|
||||
view.Text = "Hello";
|
||||
Assert.Equal ("Hello", view.Text);
|
||||
Assert.Equal ($"{Glyphs.LeftBracket} Hello {Glyphs.RightBracket}", view.TextFormatter.Text);
|
||||
|
||||
Assert.Equal ("Hello", view.Title);
|
||||
Assert.Equal ("Hello", view.TitleTextFormatter.Text);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData ("01234", 0, 0, 0, 0)]
|
||||
[InlineData ("01234", 1, 0, 1, 0)]
|
||||
[InlineData ("01234", 0, 1, 0, 1)]
|
||||
[InlineData ("01234", 1, 1, 1, 1)]
|
||||
[InlineData ("01234", 10, 1, 10, 1)]
|
||||
[InlineData ("01234", 10, 3, 10, 3)]
|
||||
[InlineData ("0_1234", 0, 0, 0, 0)]
|
||||
[InlineData ("0_1234", 1, 0, 1, 0)]
|
||||
[InlineData ("0_1234", 0, 1, 0, 1)]
|
||||
[InlineData ("0_1234", 1, 1, 1, 1)]
|
||||
[InlineData ("0_1234", 10, 1, 10, 1)]
|
||||
[InlineData ("0_12你", 10, 3, 10, 3)]
|
||||
[InlineData ("0_12你", 0, 0, 0, 0)]
|
||||
[InlineData ("0_12你", 1, 0, 1, 0)]
|
||||
[InlineData ("0_12你", 0, 1, 0, 1)]
|
||||
[InlineData ("0_12你", 1, 1, 1, 1)]
|
||||
[InlineData ("0_12你", 10, 1, 10, 1)]
|
||||
public void Button_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
|
||||
{
|
||||
// Override CM
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
var btn1 = new Button
|
||||
{
|
||||
Text = text,
|
||||
Width = width,
|
||||
Height = height
|
||||
};
|
||||
|
||||
Assert.Equal (new (expectedWidth, expectedHeight), btn1.Frame.Size);
|
||||
Assert.Equal (new (expectedWidth, expectedHeight), btn1.Viewport.Size);
|
||||
Assert.Equal (new (expectedWidth, expectedHeight), btn1.GetContentSize ());
|
||||
Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.ConstrainToSize);
|
||||
|
||||
btn1.Dispose ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0, 0, 0, 0)]
|
||||
[InlineData (1, 0, 1, 0)]
|
||||
[InlineData (0, 1, 0, 1)]
|
||||
[InlineData (1, 1, 1, 1)]
|
||||
[InlineData (10, 1, 10, 1)]
|
||||
[InlineData (10, 3, 10, 3)]
|
||||
public void Button_AbsoluteSize_DefaultText (int width, int height, int expectedWidth, int expectedHeight)
|
||||
{
|
||||
// Override CM
|
||||
Button.DefaultShadow = ShadowStyle.None;
|
||||
|
||||
var btn1 = new Button ();
|
||||
btn1.Width = width;
|
||||
btn1.Height = height;
|
||||
|
||||
Assert.Equal (new (expectedWidth, expectedHeight), btn1.Frame.Size);
|
||||
Assert.Equal (new (expectedWidth, expectedHeight), btn1.Viewport.Size);
|
||||
Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.ConstrainToSize);
|
||||
|
||||
btn1.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Button_HotKeyChanged_EventFires ()
|
||||
{
|
||||
var btn = new Button { Text = "_Yar" };
|
||||
|
||||
object sender = null;
|
||||
KeyChangedEventArgs args = null;
|
||||
|
||||
btn.HotKeyChanged += (s, e) =>
|
||||
{
|
||||
sender = s;
|
||||
args = e;
|
||||
};
|
||||
|
||||
btn.HotKeyChanged += (s, e) =>
|
||||
{
|
||||
sender = s;
|
||||
args = e;
|
||||
};
|
||||
|
||||
btn.HotKey = KeyCode.R;
|
||||
Assert.Same (btn, sender);
|
||||
Assert.Equal (KeyCode.Y, args.OldKey);
|
||||
Assert.Equal (KeyCode.R, args.NewKey);
|
||||
btn.HotKey = KeyCode.R;
|
||||
Assert.Same (btn, sender);
|
||||
Assert.Equal (KeyCode.Y, args.OldKey);
|
||||
Assert.Equal (KeyCode.R, args.NewKey);
|
||||
btn.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Button_HotKeyChanged_EventFires_WithNone ()
|
||||
{
|
||||
var btn = new Button ();
|
||||
|
||||
object sender = null;
|
||||
KeyChangedEventArgs args = null;
|
||||
|
||||
btn.HotKeyChanged += (s, e) =>
|
||||
{
|
||||
sender = s;
|
||||
args = e;
|
||||
};
|
||||
|
||||
btn.HotKey = KeyCode.R;
|
||||
Assert.Same (btn, sender);
|
||||
Assert.Equal (KeyCode.Null, args.OldKey);
|
||||
Assert.Equal (KeyCode.R, args.NewKey);
|
||||
btn.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SetupFakeDriver]
|
||||
public void Constructors_Defaults ()
|
||||
|
||||
Reference in New Issue
Block a user