diff --git a/OpenNest.Data/NestRecordFactory.cs b/OpenNest.Data/NestRecordFactory.cs index 8378e335..edb9c591 100644 --- a/OpenNest.Data/NestRecordFactory.cs +++ b/OpenNest.Data/NestRecordFactory.cs @@ -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. diff --git a/OpenNest.Tests/Data/NestRecordFactoryTests.cs b/OpenNest.Tests/Data/NestRecordFactoryTests.cs index 1a5b0d68..46d974dc 100644 --- a/OpenNest.Tests/Data/NestRecordFactoryTests.cs +++ b/OpenNest.Tests/Data/NestRecordFactoryTests.cs @@ -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() {