mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-27 08:11:38 -05:00
Auto Nest's Plates choice lets a run use only the nest's current plates (the free space beside parts already placed, then the empty plates it was given) or current plates first and then new sheets. New plates stays the default and unchanged. The review draws parts already on a plate in one gray, and the whole proposal is kept in one undo record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.5 KiB
C#
71 lines
2.5 KiB
C#
using System.Windows.Forms;
|
|
using OpenNest.Engine.Jobs;
|
|
using OpenNest.Forms;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.WinForms.Tests.Forms;
|
|
|
|
public class AutoNestFormPlateSourceTests
|
|
{
|
|
[Fact]
|
|
public void OpensOnNewPlates() => RunSta(() =>
|
|
{
|
|
using var form = new AutoNestForm(new Nest());
|
|
|
|
Assert.Equal(NestPlateSource.New, form.PlateSource);
|
|
});
|
|
|
|
[Theory]
|
|
[InlineData(NestPlateSource.Current)]
|
|
[InlineData(NestPlateSource.Both)]
|
|
public void CurrentPlatesAreNeverNestedOnTheServer(NestPlateSource source) => RunSta(() =>
|
|
{
|
|
using var form = new AutoNestForm(new Nest()) { ServerNestingAvailable = true };
|
|
var box = Assert.IsType<CheckBox>(form.Controls.Find("nestOnServerBox", true).Single());
|
|
box.Checked = true;
|
|
|
|
form.PlateSource = source;
|
|
|
|
Assert.False(box.Enabled);
|
|
Assert.False(form.NestOnServer);
|
|
form.PlateSource = NestPlateSource.New;
|
|
Assert.Equal(box.Checked, form.NestOnServer);
|
|
});
|
|
|
|
[Fact]
|
|
public void CurrentPlatesOnlyOffersNoStockOptions() => RunSta(() =>
|
|
{
|
|
using var form = new AutoNestForm(new Nest()) { OptimizePlateSize = true };
|
|
|
|
form.PlateSource = NestPlateSource.Current;
|
|
Assert.False(form.OptimizePlateSize);
|
|
|
|
form.PlateSource = NestPlateSource.Both;
|
|
Assert.True(form.OptimizePlateSize);
|
|
});
|
|
|
|
[Fact]
|
|
public void ReviewShowsPartsAlreadyPlacedWithoutCountingThem() => RunSta(() =>
|
|
{
|
|
var drawing = new Drawing("bracket", NestReviewFormTests.Rectangle());
|
|
var stock = new NestPlateStock("existing", new Size(48, 96), quantity: 1, partSpacing: 0.25);
|
|
var sheet = new ProposedPlate(0, stock, new[] { new Part(drawing, new Vector(20, 1)) })
|
|
{
|
|
Occupants = new[] { new Part(drawing, new Vector(1, 1)), new Part(drawing, new Vector(1, 30)) },
|
|
ExistingPlateNumber = 2,
|
|
};
|
|
|
|
using var form = new NestReviewForm("Review", new[] { sheet }, 0,
|
|
Array.Empty<NestUnplacedPart>(), ColorScheme.Default);
|
|
|
|
Assert.Equal(1, form.Strip.PartCount);
|
|
Assert.Equal(2, form.Strip.ExistingPartCount);
|
|
// Three 10 x 20 parts now fill the sheet's material.
|
|
Assert.Equal(600.0 / (48 * 96), form.Strip.Utilization, 6);
|
|
Assert.Contains("already on the plates (2)", form.Summary);
|
|
});
|
|
|
|
private static void RunSta(Action action) =>
|
|
StaTestThread.Run(action, TimeSpan.FromSeconds(15), "The STA test did not complete.");
|
|
}
|