mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-04 12:59:26 -05:00
Nests showed only the decimal (0.135), while the shop thinks in gauges. A nest now keeps a ThicknessName in its file, record and the server (schema v20), set from Nest Information's new box, which suggests the machine's name or the nearest standard gauge. The Open list, status bar and reports show "10 ga (0.135)"; nests saved without a name get one looked up for display only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.9 KiB
C#
99 lines
3.9 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 · 1/2\" (0.5 in)", MainStatusText.Material(nest));
|
|
|
|
nest.Thickness = 0.135;
|
|
nest.ThicknessName = "Ten";
|
|
Assert.Equal("Material: Mild Steel A36 · Ten (0.135 in)", MainStatusText.Material(nest));
|
|
|
|
nest.Thickness = 0.3;
|
|
Assert.Equal("Material: Mild Steel A36 · 0.3 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>()));
|
|
}
|
|
}
|