| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- namespace ViewsTests;
- [Collection ("Global Test Setup")]
- public class WizardStepTests
- {
- #region Constructor Tests
- [Fact]
- public void Constructor_Initializes_Properties ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.NotNull (step);
- Assert.True (step.CanFocus);
- Assert.Equal (TabBehavior.TabStop, step.TabStop);
- Assert.Equal (LineStyle.None, step.BorderStyle);
- Assert.IsType<DimFill> (step.Width);
- Assert.IsType<DimFill> (step.Height);
- }
- [Fact]
- public void Constructor_Sets_Default_Button_Text ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.Equal (string.Empty, step.BackButtonText);
- Assert.Equal (string.Empty, step.NextButtonText);
- }
- #endregion Constructor Tests
- #region Title Tests
- [Fact]
- public void Title_Can_Be_Set ()
- {
- // Arrange
- WizardStep step = new ();
- string title = "Test Step";
- // Act
- step.Title = title;
- // Assert
- Assert.Equal (title, step.Title);
- }
- [Fact]
- public void Title_Change_Raises_TitleChanged_Event ()
- {
- // Arrange
- WizardStep step = new ();
- var eventRaised = false;
- string? newTitle = null;
- step.TitleChanged += (sender, args) =>
- {
- eventRaised = true;
- newTitle = args.Value;
- };
- // Act
- step.Title = "New Title";
- // Assert
- Assert.True (eventRaised);
- Assert.Equal ("New Title", newTitle);
- }
- #endregion Title Tests
- #region HelpText Tests
- [Fact]
- public void HelpText_Can_Be_Set ()
- {
- // Arrange
- WizardStep step = new ();
- string helpText = "This is help text";
- // Act
- step.HelpText = helpText;
- // Assert
- Assert.Equal (helpText, step.HelpText);
- }
- [Fact]
- public void HelpText_Empty_By_Default ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.Equal (string.Empty, step.HelpText);
- }
- [Fact]
- public void HelpText_Setting_Calls_ShowHide ()
- {
- // Arrange
- WizardStep step = new ();
- step.BeginInit ();
- step.EndInit ();
- // Act - Setting help text should adjust padding
- step.HelpText = "Help text content";
- // Assert - Padding should have right thickness when help text is present
- Assert.True (step.Padding!.Thickness.Right > 0);
- }
- [Fact]
- public void HelpText_Clearing_Removes_Padding ()
- {
- // Arrange
- WizardStep step = new ();
- step.BeginInit ();
- step.EndInit ();
- step.HelpText = "Help text content";
- // Act - Clear help text
- step.HelpText = string.Empty;
- // Assert - Padding right should be 0 when help text is empty
- Assert.Equal (0, step.Padding!.Thickness.Right);
- }
- #endregion HelpText Tests
- #region BackButtonText Tests
- [Fact]
- public void BackButtonText_Can_Be_Set ()
- {
- // Arrange
- WizardStep step = new ();
- string buttonText = "Previous";
- // Act
- step.BackButtonText = buttonText;
- // Assert
- Assert.Equal (buttonText, step.BackButtonText);
- }
- [Fact]
- public void BackButtonText_Empty_By_Default ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.Equal (string.Empty, step.BackButtonText);
- }
- #endregion BackButtonText Tests
- #region NextButtonText Tests
- [Fact]
- public void NextButtonText_Can_Be_Set ()
- {
- // Arrange
- WizardStep step = new ();
- string buttonText = "Continue";
- // Act
- step.NextButtonText = buttonText;
- // Assert
- Assert.Equal (buttonText, step.NextButtonText);
- }
- [Fact]
- public void NextButtonText_Empty_By_Default ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.Equal (string.Empty, step.NextButtonText);
- }
- #endregion NextButtonText Tests
- #region SubView Tests
- [Fact]
- public void Can_Add_SubViews ()
- {
- // Arrange
- WizardStep step = new ();
- Label label = new () { Text = "Test Label" };
- // Act
- step.Add (label);
- // Assert
- Assert.Contains (label, step.SubViews);
- }
- [Fact]
- public void Can_Add_Multiple_SubViews ()
- {
- // Arrange
- WizardStep step = new ();
- Label label1 = new () { Text = "Label 1" };
- Label label2 = new () { Text = "Label 2" };
- TextField textField = new () { Width = 10 };
- // Act
- step.Add (label1, label2, textField);
- // Assert
- Assert.Equal (3, step.SubViews.Count);
- Assert.Contains (label1, step.SubViews);
- Assert.Contains (label2, step.SubViews);
- Assert.Contains (textField, step.SubViews);
- }
- #endregion SubView Tests
- #region Enabled Tests
- [Fact]
- public void Enabled_True_By_Default ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.True (step.Enabled);
- }
- [Fact]
- public void Enabled_Can_Be_Set_To_False ()
- {
- // Arrange
- WizardStep step = new ();
- // Act
- step.Enabled = false;
- // Assert
- Assert.False (step.Enabled);
- }
- [Fact]
- public void Enabled_Change_Raises_EnabledChanged_Event ()
- {
- // Arrange
- WizardStep step = new ();
- var eventRaised = false;
- step.EnabledChanged += (sender, args) => { eventRaised = true; };
- // Act
- step.Enabled = false;
- // Assert
- Assert.True (eventRaised);
- }
- #endregion Enabled Tests
- #region Visible Tests
- [Fact]
- public void Visible_True_By_Default ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.True (step.Visible);
- }
- [Fact]
- public void Visible_Can_Be_Changed ()
- {
- // Arrange
- WizardStep step = new ();
- // Act
- step.Visible = false;
- // Assert
- Assert.False (step.Visible);
- }
- #endregion Visible Tests
- #region HelpTextView Tests
- [Fact]
- public void HelpTextView_Added_To_Padding ()
- {
- // Arrange
- WizardStep step = new ();
- step.BeginInit ();
- step.EndInit ();
- // Act
- step.HelpText = "Help content";
- // Assert
- // The help text view should be in the Padding
- Assert.True (step.Padding!.SubViews.Count > 0);
- }
- [Fact]
- public void HelpTextView_Visible_When_HelpText_Set ()
- {
- // Arrange
- WizardStep step = new ();
- step.BeginInit ();
- step.EndInit ();
- // Act
- step.HelpText = "Help content";
- // Assert
- // When help text is set, padding right should be non-zero
- Assert.True (step.Padding!.Thickness.Right > 0);
- }
- [Fact]
- public void HelpTextView_Hidden_When_HelpText_Empty ()
- {
- // Arrange
- WizardStep step = new ();
- step.BeginInit ();
- step.EndInit ();
- step.HelpText = "Help content";
- // Act
- step.HelpText = string.Empty;
- // Assert
- // When help text is cleared, padding right should be 0
- Assert.Equal (0, step.Padding!.Thickness.Right);
- }
- #endregion HelpTextView Tests
- #region Layout Tests
- [Fact]
- public void Width_Is_Fill_After_Construction ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.IsType<DimFill> (step.Width);
- }
- [Fact]
- public void Height_Is_Fill_After_Construction ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.IsType<DimFill> (step.Height);
- }
- #endregion Layout Tests
- #region Focus Tests
- [Fact]
- public void CanFocus_True_By_Default ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.True (step.CanFocus);
- }
- [Fact]
- public void TabStop_Is_TabStop_By_Default ()
- {
- // Arrange & Act
- WizardStep step = new ();
- // Assert
- Assert.Equal (TabBehavior.TabStop, step.TabStop);
- }
- #endregion Focus Tests
- #region BorderStyle Tests
- [Fact]
- public void BorderStyle_Can_Be_Changed ()
- {
- // Arrange
- WizardStep step = new ();
- // Act
- step.BorderStyle = LineStyle.Single;
- // Assert
- Assert.Equal (LineStyle.Single, step.BorderStyle);
- }
- #endregion BorderStyle Tests
- #region Integration Tests
- [Fact]
- public void Step_With_HelpText_And_SubViews ()
- {
- // Arrange
- WizardStep step = new ()
- {
- Title = "User Information",
- HelpText = "Please enter your details"
- };
- Label nameLabel = new () { Text = "Name:" };
- TextField nameField = new () { X = Pos.Right (nameLabel) + 1, Width = 20 };
- step.Add (nameLabel, nameField);
- step.BeginInit ();
- step.EndInit ();
- // Assert
- Assert.Equal ("User Information", step.Title);
- Assert.Equal ("Please enter your details", step.HelpText);
- // SubViews includes the views we added
- Assert.Contains (nameLabel, step.SubViews);
- Assert.Contains (nameField, step.SubViews);
- Assert.True (step.Padding!.Thickness.Right > 0);
- }
- [Fact]
- public void Step_With_Custom_Button_Text ()
- {
- // Arrange & Act
- WizardStep step = new ()
- {
- Title = "Confirmation",
- BackButtonText = "Go Back",
- NextButtonText = "Accept"
- };
- // Assert
- Assert.Equal ("Confirmation", step.Title);
- Assert.Equal ("Go Back", step.BackButtonText);
- Assert.Equal ("Accept", step.NextButtonText);
- }
- [Fact]
- public void Disabled_Step_Maintains_Properties ()
- {
- // Arrange
- WizardStep step = new ()
- {
- Title = "Optional Step",
- HelpText = "This step is optional",
- Enabled = false
- };
- // Assert
- Assert.Equal ("Optional Step", step.Title);
- Assert.Equal ("This step is optional", step.HelpText);
- Assert.False (step.Enabled);
- }
- #endregion Integration Tests
- }
|