mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-13 13:41:08 -05:00
Resize to Fit snapped layouts larger than 48x48 to a hardcoded list of inch mill sheets, so a plate already on a full sheet could not shrink to its parts, and the cutoff ignored nest units and the machine's stock sizes. It now rounds the parts' extent up to the auto-size plate factor at every size through Plate.AutoSize. Removes Plate.SnapToStandardSize and PlateSizes.Recommend with its options; the sheet list and label lookup stay for Machine Config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
1.9 KiB
C#
71 lines
1.9 KiB
C#
using System.Linq;
|
|
using OpenNest.Shapes;
|
|
|
|
namespace OpenNest.Tests.Shapes;
|
|
|
|
public class PlateSizesTests
|
|
{
|
|
[Fact]
|
|
public void All_IsNotEmpty()
|
|
{
|
|
Assert.NotEmpty(PlateSizes.All);
|
|
}
|
|
|
|
[Fact]
|
|
public void All_Smallest_Is48x96()
|
|
{
|
|
var smallest = PlateSizes.All.OrderBy(e => e.Area).First();
|
|
Assert.Equal(48, smallest.Width);
|
|
Assert.Equal(96, smallest.Length);
|
|
}
|
|
|
|
[Fact]
|
|
public void All_SortedByAreaAscending()
|
|
{
|
|
for (var i = 1; i < PlateSizes.All.Count; i++)
|
|
Assert.True(PlateSizes.All[i].Area >= PlateSizes.All[i - 1].Area);
|
|
}
|
|
|
|
[Fact]
|
|
public void All_Entries_AreCanonical_WidthLessOrEqualLength()
|
|
{
|
|
foreach (var entry in PlateSizes.All)
|
|
Assert.True(entry.Width <= entry.Length, $"{entry.Label} not in canonical orientation");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(40, 40, true)] // small - fits trivially
|
|
[InlineData(48, 96, true)] // exact
|
|
[InlineData(96, 48, true)] // rotated exact
|
|
[InlineData(90, 40, true)] // rotated
|
|
[InlineData(49, 97, false)] // just over in both dims
|
|
[InlineData(50, 50, false)] // too wide in both orientations
|
|
public void Entry_Fits_RespectsRotation(double w, double h, bool expected)
|
|
{
|
|
var entry = new PlateSizes.Entry("48x96", 48, 96);
|
|
Assert.Equal(expected, entry.Fits(w, h));
|
|
}
|
|
|
|
[Fact]
|
|
public void TryGet_KnownLabel_ReturnsEntry()
|
|
{
|
|
Assert.True(PlateSizes.TryGet("48x96", out var entry));
|
|
Assert.Equal(48, entry.Width);
|
|
Assert.Equal(96, entry.Length);
|
|
}
|
|
|
|
[Fact]
|
|
public void TryGet_IsCaseInsensitive()
|
|
{
|
|
Assert.True(PlateSizes.TryGet("48X96", out var entry));
|
|
Assert.Equal(48, entry.Width);
|
|
Assert.Equal(96, entry.Length);
|
|
}
|
|
|
|
[Fact]
|
|
public void TryGet_UnknownLabel_ReturnsFalse()
|
|
{
|
|
Assert.False(PlateSizes.TryGet("bogus", out _));
|
|
}
|
|
}
|