mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-03 04:41:36 -05:00
MachineConfigForm and SavedNestsForm built their tab pages, and CuttingPanel and LeadsEditor their label / input / hint grids, with identical private helpers. Both now use ControlFactory. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using System.Windows.Forms;
|
|
using OpenNest.Controls;
|
|
|
|
namespace OpenNest.WinForms.Tests.Controls;
|
|
|
|
public class ControlFactoryTests
|
|
{
|
|
[Fact]
|
|
public void TabHoldsOnlyItsContentWithoutPadding() => RunSta(() =>
|
|
{
|
|
using var content = new Panel();
|
|
using var page = ControlFactory.Tab("Plates", content);
|
|
|
|
Assert.Equal("Plates", page.Text);
|
|
Assert.Equal(new Padding(0), page.Padding);
|
|
Assert.Same(content, Assert.Single(page.Controls.Cast<Control>()));
|
|
});
|
|
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(16)]
|
|
public void SettingsGridKeepsTheInputColumnAtTheLabelWidth(int indent) => RunSta(() =>
|
|
{
|
|
using var grid = ControlFactory.SettingsGrid(indent);
|
|
|
|
Assert.True(grid.AutoSize);
|
|
Assert.Equal(AutoSizeMode.GrowAndShrink, grid.AutoSizeMode);
|
|
Assert.Equal(3, grid.ColumnCount);
|
|
Assert.Equal(new Padding(indent, 0, 0, 0), grid.Margin);
|
|
Assert.Equal(3, grid.ColumnStyles.Count);
|
|
Assert.Equal(SizeType.Absolute, grid.ColumnStyles[0].SizeType);
|
|
Assert.Equal(150 - indent, grid.ColumnStyles[0].Width);
|
|
Assert.Equal(SizeType.AutoSize, grid.ColumnStyles[1].SizeType);
|
|
Assert.Equal(SizeType.AutoSize, grid.ColumnStyles[2].SizeType);
|
|
});
|
|
|
|
private static void RunSta(Action action) =>
|
|
StaTestThread.Run(action, TimeSpan.FromSeconds(30), "The STA test did not complete.");
|
|
}
|