Files
OpenNest/OpenNest.WinForms.Tests/Controls/ControlFactoryTests.cs
T
ajandClaude Opus 5.5 7bff9baa23 refactor(desktop): share code-built tab pages and settings grids
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>
2026-11-01 10:21:27 -05:00

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.");
}