Files
OpenNest/OpenNest.Tests/Data/SetReleaseTextTests.cs
T
ajandClaude Opus 5.5 cc731ff3d6 feat(desktop): release drawing sets into draft nests and track them
A set is only useful on the floor once it becomes nests. Release on the
Sets tab previews one row per material group with a kit multiplier, an
archived-drawing toggle and a tick per group, then builds each ticked
group's nest as File > New would, in the group's units, uploads it as a
Draft, opens it in its own tab bound to the server record and records the
release. Every group's outcome stays on screen, and a release whose
nests exist but whose record failed can be recorded again.

Releases shows each release's nests and how far they have got ("2 of 3
cut"), and Nest Info names the release a nest came from, so a kit run can
be followed across its nests. Plate defaults convert between inches and
millimeters so a group drawn in other units still gets sensible plates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 15:12:11 -04:00

81 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using OpenNest.Data;
using OpenNest.Geometry;
namespace OpenNest.Tests.Data;
public class SetReleaseTextTests
{
private static SetReleaseNest Nest(NestStatus status, bool deleted = false, bool joined = true) => new()
{
NestId = Guid.NewGuid(),
MaterialName = "Synthetic Steel",
MaterialGrade = "Grade A",
Thickness = 0.25,
Units = Units.Inches,
CutType = CutType.Waterjet,
Nest = joined ? new NestRecord { Name = "N1", Status = status, Deleted = deleted } : null,
};
[Fact]
public void Progress_CountsCutNestsAndLeavesDeletedOnesOut()
{
Assert.Equal("2 of 3 cut", SetReleaseText.Progress(new SetReleaseRecord
{
Nests = new[] { Nest(NestStatus.HasBeenCut), Nest(NestStatus.HasBeenCut), Nest(NestStatus.Draft) },
}));
Assert.Equal("0 of 1 cut, 2 deleted", SetReleaseText.Progress(new SetReleaseRecord
{
Nests = new[] { Nest(NestStatus.ToBeCut), Nest(NestStatus.HasBeenCut, deleted: true), Nest(NestStatus.Quote, joined: false) },
}));
Assert.Equal("All nests deleted", SetReleaseText.Progress(new SetReleaseRecord
{
Nests = new[] { Nest(NestStatus.Draft, deleted: true), Nest(NestStatus.Draft, deleted: true) },
}));
}
[Fact]
public void NestState_AndGroup_DescribeOneNest()
{
Assert.Equal("To Be Cut", SetReleaseText.NestState(Nest(NestStatus.ToBeCut)));
Assert.Equal("Deleted", SetReleaseText.NestState(Nest(NestStatus.ToBeCut, deleted: true)));
Assert.Equal("Synthetic Steel Grade A 0.25 in waterjet", SetReleaseText.Group(Nest(NestStatus.Draft)));
}
[Fact]
public void Origin_NamesTheSetRevisionMultiplierAndWho()
{
var text = SetReleaseText.Origin(new SetReleaseRecord
{
SetName = "Synthetic kit",
SetRevision = 3,
Multiplier = 2,
ReleasedBy = "Synthetic operator",
});
Assert.Equal("Released from set 'Synthetic kit' revision 3 ×2 by Synthetic operator", text);
}
[Fact]
public void NestDefaults_ConvertedTo_ScalesPlateDefaultsBetweenUnits()
{
var inches = new NestDefaults
{
Units = Units.Inches,
Size = new Size(60, 120),
Quadrant = 3,
PartSpacing = 0.125,
EdgeSpacing = new Spacing(0.5, 0.25, 0.5, 0.25),
};
var millimeters = inches.ConvertedTo(Units.Millimeters);
var back = millimeters.ConvertedTo(Units.Inches);
Assert.Equal((Units.Millimeters, 1524.0, 3048.0, 3, 3.175), (millimeters.Units, millimeters.Size.Width,
millimeters.Size.Length, millimeters.Quadrant, millimeters.PartSpacing));
Assert.Equal((12.7, 6.35, 12.7, 6.35), (millimeters.EdgeSpacing.Left, millimeters.EdgeSpacing.Bottom,
millimeters.EdgeSpacing.Right, millimeters.EdgeSpacing.Top));
Assert.Equal((60.0, 120.0, 0.125), (back.Size.Width, back.Size.Length, back.PartSpacing));
Assert.NotSame(inches, inches.ConvertedTo(Units.Inches));
}
}