mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-07 17:45:46 -05:00
Nest drawings can require no parts, but the CAD Converter's quantity spinner had a minimum of 1, so Edit Drawings in Converter threw ArgumentOutOfRangeException as soon as such a drawing was selected. Lowering the minimum to 0 lets the converter load it and hand the drawing back with its quantity still 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using OpenNest.Bending;
|
|
using OpenNest.Forms;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.IO;
|
|
|
|
namespace OpenNest.WinForms.Tests.Forms;
|
|
|
|
/// <summary>
|
|
/// A nest drawing may require no parts (quantity 0); editing it in the CAD Converter must keep that.
|
|
/// </summary>
|
|
public class CadConverterQuantityTests
|
|
{
|
|
[Fact]
|
|
public void LoadingADrawingThatRequiresNoParts_KeepsItsQuantityAtZero() => ArchUnitsTests.RunSta(() =>
|
|
{
|
|
using var form = new CadConverterForm();
|
|
form.WindowState = FormWindowState.Normal;
|
|
form.StartPosition = FormStartPosition.Manual;
|
|
form.Location = new Point(0, 0);
|
|
form.Size = new System.Drawing.Size(1200, 800);
|
|
form.Show();
|
|
|
|
form.LoadDrawings([Square(0)]);
|
|
|
|
var drawing = Assert.Single(form.GetDrawings());
|
|
Assert.Equal(0, drawing.Quantity.Required);
|
|
form.Close();
|
|
});
|
|
|
|
private static Drawing Square(int quantity)
|
|
{
|
|
var entities = new List<Entity>
|
|
{
|
|
new Line(0, 0, 10, 0), new Line(10, 0, 10, 10), new Line(10, 10, 0, 10), new Line(0, 10, 0, 0),
|
|
};
|
|
foreach (var e in entities)
|
|
e.Layer = new Layer("0") { IsVisible = true };
|
|
var drawing = CadImporter.BuildDrawing(new CadImportResult { Entities = entities, Name = "square" }, entities,
|
|
new List<Bend>(), 1, null, null);
|
|
drawing.Quantity.Required = quantity;
|
|
return drawing;
|
|
}
|
|
}
|