Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -873,5 +873,59 @@ public void CheckBox_ProcessMnemonic_ValidCases(bool useMnemonic, char charCode,
checkBox.CheckState.Should().Be(CheckState.Checked);
}

[WinFormsTheory]
[InlineData(Appearance.Button, FlatStyle.Standard, "Test", 12, 8, 100, 20)]
[InlineData(Appearance.Normal, FlatStyle.System, "Test", 12, 8, 100, 20)]
[InlineData(Appearance.Normal, FlatStyle.Flat, "Test", 12, 8, 100, 20)]
[InlineData(Appearance.Normal, FlatStyle.Standard, "Test", 12, 8, 100, 20)]
public void CheckBox_GetPreferredSizeCore_VariousStyles_ReturnsExpected(
Appearance appearance, FlatStyle flatStyle, string text, int fontSize, int padding, int width, int height)
{
using SubCheckBox control = (SubCheckBox)CreateButton();
control.Appearance = appearance;
control.FlatStyle = flatStyle;
control.Text = text;
control.Font = new Font(FontFamily.GenericSansSerif, fontSize);
control.Padding = new Padding(padding);

Size proposed = new(width, height);

if (appearance == Appearance.Button)
{
Size size = control.GetPreferredSizeCore(proposed);
size.Width.Should().BeGreaterThan(0);
size.Height.Should().BeGreaterThan(0);
}

else if (flatStyle == FlatStyle.System)
{
Size size = control.GetPreferredSizeCore(proposed);
size.Width.Should().BeGreaterThan(0);
size.Height.Should().BeGreaterThan(0);
}

else
{
Size size = control.GetPreferredSizeCore(proposed);
size.Width.Should().BeGreaterThan(0);
size.Height.Should().BeGreaterThan(0);
}
}

[WinFormsFact]
public void CheckBox_GetPreferredSizeCore_EnsuresMinimumHeight()
{
using SubCheckBox control = (SubCheckBox)CreateButton();
control.FlatStyle = FlatStyle.System;
control.Text = "A";
control.Font = new Font(FontFamily.GenericSansSerif, 1);
control.Padding = Padding.Empty;

Size proposed = new(1, 1);
Size result = control.GetPreferredSizeCore(proposed);

result.Height.Should().BeGreaterThanOrEqualTo(13);
}

protected override ButtonBase CreateButton() => new SubCheckBox();
}