mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 13:21:34 -05:00
MainStatusText words the main window's location, machine, material, utilization and version labels as WinForms does, with the labels' tooltips and the StatusBarLocationFollowsMouse setting both apps keep. MachineMenu lists the machines for Nest > Machine and the machine label (by name, the nest's checked, one no longer on file checked and disabled), and MachineSettingsSource.ApplyMachine assigns one with its support grid, cut-off defaults and spacing. PlateWorkGuard holds the "Finish or cancel the current nesting or plate action first." check. The WinForms main window delegates to them unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using OpenNest.Data;
|
|
using OpenNest.Forms;
|
|
|
|
namespace OpenNest.Desktop.Tests.Forms;
|
|
|
|
public class MachineMenuTests
|
|
{
|
|
private static MachineConfig Machine(string name) => new() { Name = name };
|
|
|
|
[Fact]
|
|
public void NoNest_ListsOnlyADisabledNote()
|
|
{
|
|
var item = Assert.Single(MachineMenu.Items(null!, new[] { Machine("Laser") }));
|
|
|
|
Assert.Equal(MachineMenu.NoNestText, item.Text);
|
|
Assert.False(item.Enabled);
|
|
Assert.Null(item.Machine);
|
|
}
|
|
|
|
[Fact]
|
|
public void Machines_AreListedByNameWithTheNestsChecked()
|
|
{
|
|
var laser = Machine("laser");
|
|
var fiber = Machine("Fiber");
|
|
var nest = new Nest { Machine = new NestMachine(laser.Id, laser.Name) };
|
|
|
|
var items = MachineMenu.Items(nest, new[] { laser, fiber });
|
|
|
|
Assert.Equal(new[] { "Fiber", "laser" }, items.Select(i => i.Text));
|
|
Assert.Equal(new[] { false, true }, items.Select(i => i.Checked));
|
|
Assert.All(items, i => Assert.True(i.Enabled));
|
|
Assert.Same(fiber, items[0].Machine);
|
|
Assert.True(MachineMenu.IsAssigned(nest, laser));
|
|
Assert.False(MachineMenu.IsAssigned(nest, fiber));
|
|
}
|
|
|
|
[Fact]
|
|
public void AMachineNoLongerOnFile_StaysCheckedAndDisabled()
|
|
{
|
|
var nest = new Nest { Machine = new NestMachine(Guid.NewGuid(), "Old Plasma") };
|
|
|
|
var items = MachineMenu.Items(nest, new[] { Machine("Laser") });
|
|
|
|
Assert.Equal(2, items.Count);
|
|
var gone = items[1];
|
|
Assert.Equal("Old Plasma (not on file)", gone.Text);
|
|
Assert.True(gone.Checked);
|
|
Assert.False(gone.Enabled);
|
|
Assert.Null(gone.Machine);
|
|
}
|
|
|
|
[Fact]
|
|
public void NoMachines_PointsToMachineConfiguration()
|
|
{
|
|
var item = Assert.Single(MachineMenu.Items(new Nest(), Array.Empty<MachineConfig>()));
|
|
|
|
Assert.Equal(MachineMenu.NoMachinesText, item.Text);
|
|
Assert.False(item.Enabled);
|
|
}
|
|
}
|