Files
OpenNest/OpenNest.WinForms.Tests/Forms/EditNestPlateStockTooltipTests.cs
ajandClaude Opus 5.5 15750949dd feat(nest): plates name the ledger item each sheet is cut from
Auto Nest on MaterialLedger stock now records which inventory item each
physical sheet uses, so ML can hold exactly those items instead of matching
by size.

- Core: Plate.StockItemCodes (entry i = sheet i of Quantity; empty = uncoded).
  Core invalidates it: a resize clears it (turning the sheet keeps it), a lower
  Quantity truncates it, a nest material/grade/thickness change clears every
  plate's, ClearAll clears it and new plates never copy it.
- Desktop Auto Nest: after a kept proposal is committed, LedgerStockAssignment
  deals each ledger row's codes to its plates in Nest.Plates order (bundles
  repeat their code; clamp-removal variants use their base row). Rejected,
  discarded or cancelled proposals never reach it. NestPipelineCommit.PairWithStock
  pairs committed plates with their solved stock; the engine stays ledger-free.
- Plate list tooltip: "Stock: CODE (location)"; locations are display-only.
- nest.json: optional plate stockItemCodes, omitted when empty, read leniently.
- /api/nests/{id}/sheets: new plates[] { index, width, length, quantity,
  stockItemCodes }; sheets[] unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 17:40:44 -04:00

34 lines
1.3 KiB
C#

using System.Windows.Forms;
using OpenNest.Forms;
using OpenNest.Shapes;
namespace OpenNest.WinForms.Tests.Forms;
/// <summary>The plate list names each coded plate's inventory item, with its ledger location when known.</summary>
public class EditNestPlateStockTooltipTests
{
[Fact]
public void CodedPlateShowsItsStockInThePlateListTooltip() => RunSta(() =>
{
var nest = new Nest("stock tooltip");
var drawing = new RectangleShape { Name = "SYN", Length = 4, Width = 2 }.GetDrawing();
nest.Drawings.Add(drawing);
var plate = nest.CreatePlate();
plate.Parts.Add(new Part(drawing));
plate.StockItemCodes = ["DROP-1182"];
using var form = new EditNestForm(nest);
form.PlateView.SetOverlapAutoCheck(null);
form.LedgerLocations["DROP-1182"] = "B3";
form.UpdatePlateList();
var plates = Assert.IsType<ListView>(Assert.Single(form.Controls.Find("platesListView", true)));
Assert.True(plates.ShowItemToolTips);
Assert.Equal("Stock: DROP-1182 (B3)", plates.Items[0].ToolTipText);
Assert.Equal("", plates.Items[^1].ToolTipText);
});
private static void RunSta(System.Action testBody) =>
StaTestThread.Run(testBody, TimeSpan.FromSeconds(60), "The stock tooltip STA test did not complete.");
}