Files
OpenNest/OpenNest.Desktop.Tests/TestNests.cs
T
ajandClaude Opus 5.5 9c0a543d79 feat(desktop): give each nest tab its own undo history
NestTab starts a NestUndoRecorder once the trailing empty plate is in
place, so opening is not an edit. Modified now follows the history's save
point and unscoped edits (undoing back to the saved state clears it), and
SaveAs records an unscoped edit before marking the save point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 19:27:07 -05:00

34 lines
1.1 KiB
C#

using OpenNest.CNC;
using OpenNest.Geometry;
namespace OpenNest.Desktop.Tests;
internal static class TestNests
{
/// <summary>Records an edit of the tab's nest, as a desktop command does.</summary>
public static void Edit(NestTab tab) =>
tab.Undo.RecordChange("Edit", () => tab.Document.Nest.Notes += "edited");
/// <summary>A nest with one 48x96 plate holding one 10x10 square part.</summary>
public static Nest OneSquare()
{
var program = new Program();
program.Codes.Add(new RapidMove(new Vector(0, 0)));
program.Codes.Add(new LinearMove(new Vector(10, 0)));
program.Codes.Add(new LinearMove(new Vector(10, 10)));
program.Codes.Add(new LinearMove(new Vector(0, 10)));
program.Codes.Add(new LinearMove(new Vector(0, 0)));
var drawing = new Drawing("square", program);
drawing.Quantity.Required = 1;
var plate = new Plate(new Size(48, 96));
plate.Parts.Add(new Part(drawing));
var nest = new Nest { Name = "test" };
nest.Drawings.Add(drawing);
nest.Plates.Add(plate);
return nest;
}
}