From a88c056f4b1d4c8461f43b4e28459b78d91984c4 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Mon, 26 Oct 2026 08:55:04 -0400 Subject: [PATCH] test(io): expect saved part cutting parameters after reload These round-trip tests pinned the old behaviour, where a part with a saved lead-in program read back with null cutting parameters. Since 7abf0701 the part keeps the settings its leads were built with, as an owned copy that stays separate from the plate's settings. Co-Authored-By: Claude Opus 5.5 --- OpenNest.Tests/IO/PartLeadInSerializationTests.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OpenNest.Tests/IO/PartLeadInSerializationTests.cs b/OpenNest.Tests/IO/PartLeadInSerializationTests.cs index 10a1f70c..2b97db4c 100644 --- a/OpenNest.Tests/IO/PartLeadInSerializationTests.cs +++ b/OpenNest.Tests/IO/PartLeadInSerializationTests.cs @@ -26,7 +26,10 @@ public class PartLeadInSerializationTests Assert.Equal(expected.Location, actual.Location); Assert.Equal(expected.Rotation, actual.Rotation, 8); AssertBox(expected.BoundingBox, actual.BoundingBox); - Assert.Null(actual.CuttingParameters); + // The settings the leads were built with come back with them, as an owned copy. + Assert.NotSame(expected.CuttingParameters, actual.CuttingParameters); + Assert.Equal(CuttingParametersSerializer.Serialize(expected.CuttingParameters), + CuttingParametersSerializer.Serialize(actual.CuttingParameters)); Assert.Same(loaded.Drawings.First(), actual.BaseDrawing); Assert.NotEmpty(actual.Program.SubPrograms); foreach (var call in actual.Program.Codes.OfType()) @@ -242,7 +245,12 @@ public class PartLeadInSerializationTests Assert.Equal(0.875, Assert.IsType(loaded.Plates[1].CuttingParameters.ExternalLeadIn).Radius); Assert.NotSame(parameters, loaded.Plates[1].CuttingParameters); Assert.Equal(program, NestWriter.GetProgramText(loaded.Plates[0].Parts[0].Program)); - Assert.Null(loaded.Plates[0].Parts[0].CuttingParameters); + // The part keeps the settings its leads were built with, not the plate's new ones. + var partParameters = loaded.Plates[0].Parts[0].CuttingParameters; + Assert.NotSame(parameters, partParameters); + Assert.Null(partParameters.MachineName); + Assert.Equal(CuttingParametersSerializer.Serialize(first.Parts[0].CuttingParameters), + CuttingParametersSerializer.Serialize(partParameters)); Assert.False(loaded.Plates[1].Parts[0].HasManualLeadIns); }