mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 06:41:42 -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>
92 lines
3.6 KiB
C#
92 lines
3.6 KiB
C#
using System.Globalization;
|
|
using System.Reflection;
|
|
using OpenNest.Desktop.Interaction;
|
|
using OpenNest.Desktop.Tests.Interaction;
|
|
using OpenNest.Forms;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Desktop.Tests.Forms;
|
|
|
|
public sealed class MainStatusTextTests : IDisposable
|
|
{
|
|
private readonly CultureInfo previous = CultureInfo.CurrentCulture;
|
|
|
|
public MainStatusTextTests() => CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
|
|
|
|
public void Dispose() => CultureInfo.CurrentCulture = previous;
|
|
|
|
[Fact]
|
|
public void Location_ShowsBothCoordinatesToFourPlaces() =>
|
|
Assert.Equal("Location: [1,234.5000, -0.1250]", MainStatusText.Location(new Vector(1234.5, -0.125)));
|
|
|
|
[Fact]
|
|
public void Utilization_ShowsOnePlaceOfPercent() =>
|
|
Assert.Equal("Util: 61.3 %", MainStatusText.Utilization(0.6125));
|
|
|
|
[Fact]
|
|
public void Material_ShowsNameGradeAndThicknessWithUnits()
|
|
{
|
|
Assert.Equal("Material: Steel A36 · 0.25 in", MainStatusText.Material("Steel", " A36 ", 0.25, Units.Inches));
|
|
Assert.Equal("Material: 304 SS · 3 mm", MainStatusText.Material(" 304 SS ", "", 3, Units.Millimeters));
|
|
Assert.Equal("Material: 0.1875 in", MainStatusText.Material(null, null, 0.1875, Units.Inches));
|
|
Assert.Equal("Material: (none)", MainStatusText.Material("", " ", 0, Units.Inches));
|
|
}
|
|
|
|
[Fact]
|
|
public void Material_ReadsTheNest()
|
|
{
|
|
var nest = new Nest { Thickness = 0.5, Units = Units.Inches, Material = new Material("Mild Steel", "A36", 0.2836) };
|
|
|
|
Assert.Equal("Material: Mild Steel A36 · 0.5 in", MainStatusText.Material(nest));
|
|
}
|
|
|
|
[Fact]
|
|
public void Machine_ShowsTheNestsMachine()
|
|
{
|
|
Assert.Equal("Machine: CL-980", MainStatusText.Machine(new NestMachine(Guid.NewGuid(), " CL-980 ")));
|
|
Assert.Equal("Machine: (unnamed)", MainStatusText.Machine(new NestMachine(Guid.NewGuid(), "")));
|
|
Assert.Equal("Machine: (none)", MainStatusText.Machine(null!));
|
|
}
|
|
|
|
[Fact]
|
|
public void Version_DropsBuildMetadata()
|
|
{
|
|
Assert.Equal("v1.2.3", MainStatusText.Version("1.2.3"));
|
|
Assert.DoesNotContain("+", MainStatusText.DisplayVersion(typeof(MainStatusText).Assembly));
|
|
Assert.Equal(
|
|
typeof(MainStatusText).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!
|
|
.InformationalVersion.Split('+')[0],
|
|
MainStatusText.DisplayVersion(typeof(MainStatusText).Assembly));
|
|
}
|
|
|
|
[Fact]
|
|
public void LocationMode_FollowsTheMouseUnlessSavedOff()
|
|
{
|
|
var settings = new Dictionary<string, string>();
|
|
Assert.True(MainStatusText.ReadLocationFollowsMouse(settings));
|
|
|
|
MainStatusText.WriteLocationFollowsMouse(settings, false);
|
|
Assert.Equal("False", settings[MainStatusText.LocationFollowsMouseName]);
|
|
Assert.False(MainStatusText.ReadLocationFollowsMouse(settings));
|
|
|
|
settings[MainStatusText.LocationFollowsMouseName] = "nonsense";
|
|
Assert.True(MainStatusText.ReadLocationFollowsMouse(settings));
|
|
}
|
|
|
|
[Fact]
|
|
public void PlateWork_IsBusyWhileAJobRunsOrAToolIsMidTask()
|
|
{
|
|
var plate = InteractionFixtures.Plate();
|
|
var host = new TestToolHost(plate);
|
|
var tools = new[] { host.Tools.Current };
|
|
|
|
Assert.False(PlateWorkGuard.IsBusy(false, tools));
|
|
Assert.True(PlateWorkGuard.IsBusy(true, tools));
|
|
|
|
// As the WinForms select action: a selection is work in progress.
|
|
host.Selection.Select(plate.Parts[0]);
|
|
Assert.True(PlateWorkGuard.IsBusy(false, tools));
|
|
Assert.False(PlateWorkGuard.IsBusy(false, Array.Empty<PlateTool>()));
|
|
}
|
|
}
|