mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* 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>
68 lines
2.6 KiB
C#
68 lines
2.6 KiB
C#
using System.Globalization;
|
|
using UnitTests;
|
|
|
|
namespace Terminal.Gui.ViewsTests;
|
|
|
|
public class DatePickerTests
|
|
{
|
|
[Fact]
|
|
[AutoInitShutdown]
|
|
public void DatePicker_ShouldNot_SetDateOutOfRange_UsingNextMonthButton ()
|
|
{
|
|
var date = new DateTime (9999, 11, 15);
|
|
var datePicker = new DatePicker (date);
|
|
|
|
var top = new Toplevel ();
|
|
top.Add (datePicker);
|
|
Application.Begin (top);
|
|
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_dateField"), datePicker.Focused);
|
|
|
|
// Set focus to next month button
|
|
datePicker.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_calendar"), datePicker.Focused);
|
|
datePicker.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_previousMonthButton"), datePicker.Focused);
|
|
datePicker.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_nextMonthButton"), datePicker.Focused);
|
|
|
|
// Change month to December
|
|
Assert.False (Application.RaiseKeyDownEvent (Key.Enter));
|
|
Assert.Equal (12, datePicker.Date.Month);
|
|
|
|
// Next month button is disabled, so focus advanced to edit field
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_previousMonthButton"), datePicker.Focused);
|
|
|
|
top.Dispose ();
|
|
}
|
|
|
|
[Fact]
|
|
[AutoInitShutdown]
|
|
public void DatePicker_ShouldNot_SetDateOutOfRange_UsingPreviousMonthButton ()
|
|
{
|
|
var date = new DateTime (1, 2, 15);
|
|
var datePicker = new DatePicker (date);
|
|
var top = new Toplevel ();
|
|
|
|
// Move focus to previous month button
|
|
top.Add (datePicker);
|
|
Application.Begin (top);
|
|
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_dateField"), datePicker.Focused);
|
|
|
|
datePicker.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_calendar"), datePicker.Focused);
|
|
datePicker.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop);
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_previousMonthButton"), datePicker.Focused);
|
|
|
|
// Change month to January
|
|
Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
|
|
Assert.Equal (1, datePicker.Date.Month);
|
|
|
|
// Next prev button is disabled, so focus advanced to edit button
|
|
Assert.Equal (datePicker.SubViews.First (v => v.Id == "_calendar"), datePicker.Focused);
|
|
|
|
top.Dispose ();
|
|
}
|
|
}
|