mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-02 16:49:25 -05:00
PlateCommands ports the WinForms nest window's plate commands, each one undo step under its WinForms label: Remove Plate, Remove Empty Plates, Duplicate Plate (the copy current, with its own cutting parameters), Move Plate and its Alt+Up/Alt+Down target, Rotate Plate (90 degrees either way or 180), Resize Plate to its parts by the auto-size factor, Set Nest Default Plate, and Edit Plate's commit, where an empty plate's new settings become the nest's defaults and the nested quantities are counted again. NewNestDefaults is what Set as Default saves for new nests: the plate, the saved common-line usage and the nest's machine. PlateEditValues is what Edit Plate edits (quantity, size, part and edge spacing, quadrant, outline), when Done applies and how it writes the plate; SheetOutlineImport reads an outline from a CAD file, and SvgScale holds the scale prompt for an SVG that does not state its size. PlateListRow is the Plates list's row text and its drag drop slots; QuadrantPick the quadrant picker's hit test and cells. The WinForms nest window, plate list, Edit Plate dialog, quadrant picker, SVG scale prompt and Save Current as Defaults delegate to them with unchanged behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using OpenNest.Geometry;
|
||
|
||
namespace OpenNest.Desktop.Tests.Plates;
|
||
|
||
public class PlateListRowTests
|
||
{
|
||
[Fact]
|
||
public void APlateWithParts_ShowsItsNumberSizePartsAndUtilization()
|
||
{
|
||
var nest = TestNests.OneSquare();
|
||
nest.Plates[0].Quantity = 3;
|
||
nest.Plates.Add(new Plate(new Size(48, 96)));
|
||
|
||
var rows = PlateListRow.For(nest.Plates);
|
||
|
||
Assert.Equal("Plate 1", rows[0].Name);
|
||
Assert.Equal(nest.Plates[0].Size.ToString(4), rows[0].Size);
|
||
Assert.Equal("1 part", rows[0].Parts);
|
||
Assert.Equal($"{nest.Plates[0].Utilization():P0} utilized", rows[0].Utilization);
|
||
Assert.Equal("×3", rows[0].Quantity);
|
||
}
|
||
|
||
[Fact]
|
||
public void TheTrailingEmptyPlate_IsTheNewPlate()
|
||
{
|
||
var nest = TestNests.OneSquare();
|
||
nest.Plates.Add(new Plate(new Size(48, 96)));
|
||
|
||
var row = PlateListRow.For(nest.Plates, 1);
|
||
|
||
Assert.Equal("New plate", row.Name);
|
||
Assert.Equal("Empty", row.Parts);
|
||
Assert.Equal("", row.Utilization);
|
||
Assert.Equal("", row.Quantity);
|
||
}
|
||
|
||
[Fact]
|
||
public void AnEmptyPlateBeforeTheEnd_IsNumbered()
|
||
{
|
||
var nest = TestNests.OneSquare();
|
||
nest.Plates.Insert(0, new Plate(new Size(48, 96)));
|
||
|
||
var row = PlateListRow.For(nest.Plates, 0);
|
||
|
||
Assert.Equal("Plate 1", row.Name);
|
||
Assert.Equal("0 parts", row.Parts);
|
||
}
|
||
|
||
[Theory]
|
||
[InlineData(0, true, 3, 0)]
|
||
[InlineData(0, false, 3, 1)]
|
||
[InlineData(2, false, 3, 3)]
|
||
[InlineData(3, true, 3, 3)] // the new-plate row
|
||
[InlineData(-1, false, 3, 3)] // below the rows
|
||
public void DropSlot_IsBeforeOrAfterTheRowUnderThePointer(int row, bool upper, int movable, int expected) =>
|
||
Assert.Equal(expected, PlateListRow.DropSlot(row, upper, movable));
|
||
|
||
[Theory]
|
||
[InlineData(0, 3, 2)]
|
||
[InlineData(2, 0, 0)]
|
||
[InlineData(1, 1, 1)]
|
||
public void DropTarget_AccountsForTheDraggedPlatesOwnPlace(int from, int slot, int expected) =>
|
||
Assert.Equal(expected, PlateListRow.DropTarget(from, slot));
|
||
}
|