mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-26 22:01:06 -04:00
fix(data): leave the trailing empty plate out of nest record plate counts
The editor keeps an empty plate at the end of a nest as its new-plate slot. Counting it made database records report one plate too many, so the record now uses the same displayed-plate count as the UI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e82f26b976
commit
add94dff6c
2 files changed
+17
-1
No files matched your search
@@ -46,7 +46,8 @@ public static class NestRecordFactory
|
||||
Material = nest.Material?.Name ?? "",
|
||||
Thickness = nest.Thickness,
|
||||
Status = nest.Status,
|
||||
PlateCount = nest.Plates.Count,
|
||||
// The trailing empty plate is the editor's new-plate slot, not a plate of the nest.
|
||||
PlateCount = PlateDisplayNumbering.DisplayedPlateCount(nest.Plates),
|
||||
PartCount = nest.Plates.Sum(CountNonCutoffParts),
|
||||
// Nest has no separate "comments" field; Notes is the closest analog
|
||||
// shown in the nest info dialog, so it round-trips as Comments here.
|
||||
|
||||
@@ -115,6 +115,21 @@ public class NestRecordFactoryTests
|
||||
Assert.Equal("", record.MadeBy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FromNest_TrailingEmptyPlate_NotCounted()
|
||||
{
|
||||
var nest = new Nest("Sentinel");
|
||||
var drawing = new Drawing("A");
|
||||
nest.Drawings.Add(drawing);
|
||||
nest.CreatePlate().Parts.Add(new Part(drawing));
|
||||
nest.CreatePlate();
|
||||
|
||||
var record = NestRecordFactory.FromNest(nest, Guid.NewGuid(), fileSize: 0);
|
||||
|
||||
Assert.Equal(1, record.PlateCount);
|
||||
Assert.Equal(1, record.PartCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FromNest_PreservesGivenId()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user