mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-15 15:55:36 -05:00
test(cutting): share the lead-in tests' point and profile helpers
Three lead-in test classes kept identical AssertPoint and Profile helpers. They now import LeadInTestHelpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c027793077
commit
1d310b373e
4 files changed
+23
-27
No files matched your search
@@ -2,6 +2,7 @@ using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingStrategy;
|
||||
using OpenNest.Geometry;
|
||||
using OpenNest.Math;
|
||||
using static OpenNest.Tests.CuttingStrategy.LeadInTestHelpers;
|
||||
|
||||
namespace OpenNest.Tests.CuttingStrategy;
|
||||
|
||||
@@ -168,9 +169,6 @@ public class ArcLeadInTangentTests
|
||||
program.Codes.Add(new LinearMove(point));
|
||||
}
|
||||
|
||||
private static ShapeProfile Profile(Part part) => new(part.Program.ToGeometry()
|
||||
.Where(e => SpecialLayers.IsMaterial(e.Layer)).ToList());
|
||||
|
||||
private static IEnumerable<Entity> Leads(Part part, Layer layer) =>
|
||||
part.Program.ToGeometry().Where(e => e.Layer == layer);
|
||||
|
||||
@@ -182,10 +180,4 @@ public class ArcLeadInTangentTests
|
||||
var radial = (point - arc.Center).Normalize();
|
||||
return arc.IsReversed ? new Vector(radial.Y, -radial.X) : new Vector(-radial.Y, radial.X);
|
||||
}
|
||||
|
||||
private static void AssertPoint(Vector expected, Vector actual)
|
||||
{
|
||||
Assert.Equal(expected.X, actual.X, 8);
|
||||
Assert.Equal(expected.Y, actual.Y, 8);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingStrategy;
|
||||
using OpenNest.Geometry;
|
||||
using static OpenNest.Tests.CuttingStrategy.LeadInTestHelpers;
|
||||
|
||||
namespace OpenNest.Tests.CuttingStrategy;
|
||||
|
||||
@@ -283,9 +284,6 @@ public class CutoutCornerLeadInTests
|
||||
program.Codes.Add(new LinearMove(point));
|
||||
}
|
||||
|
||||
private static ShapeProfile Profile(Part part) => new(part.Program.ToGeometry()
|
||||
.Where(e => SpecialLayers.IsMaterial(e.Layer)).ToList());
|
||||
|
||||
private static Shape Cutout(Part part) => Assert.Single(Profile(part).Cutouts);
|
||||
|
||||
private static Line SingleLeadIn(Part part) => Assert.IsType<Line>(Assert.Single(
|
||||
@@ -297,10 +295,4 @@ public class CutoutCornerLeadInTests
|
||||
AssertPoint(corner + direction / direction.DistanceTo(Vector.Zero) * LeadLength, lead.StartPoint);
|
||||
Assert.Equal(LeadLength, lead.Length, 8);
|
||||
}
|
||||
|
||||
private static void AssertPoint(Vector expected, Vector actual)
|
||||
{
|
||||
Assert.Equal(expected.X, actual.X, 8);
|
||||
Assert.Equal(expected.Y, actual.Y, 8);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingStrategy;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest.Tests.CuttingStrategy;
|
||||
|
||||
/// <summary>Helpers the lead-in tests share. Import with <c>using static</c>.</summary>
|
||||
internal static class LeadInTestHelpers
|
||||
{
|
||||
/// <summary>Asserts both coordinates match to 8 decimal places.</summary>
|
||||
public static void AssertPoint(Vector expected, Vector actual)
|
||||
{
|
||||
Assert.Equal(expected.X, actual.X, 8);
|
||||
Assert.Equal(expected.Y, actual.Y, 8);
|
||||
}
|
||||
|
||||
/// <summary>The part's shape profile, leaving out rapid, scribe and break layers.</summary>
|
||||
public static ShapeProfile Profile(Part part) => new(part.Program.ToGeometry()
|
||||
.Where(e => SpecialLayers.IsMaterial(e.Layer)).ToList());
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingStrategy;
|
||||
using OpenNest.Geometry;
|
||||
using static OpenNest.Tests.CuttingStrategy.LeadInTestHelpers;
|
||||
|
||||
namespace OpenNest.Tests.CuttingStrategy;
|
||||
|
||||
@@ -254,9 +255,6 @@ public class PerimeterCornerLeadInTests
|
||||
program.Codes.Add(new LinearMove(point));
|
||||
}
|
||||
|
||||
private static ShapeProfile Profile(Part part) => new(part.Program.ToGeometry()
|
||||
.Where(e => SpecialLayers.IsMaterial(e.Layer)).ToList());
|
||||
|
||||
private static Shape Perimeter(Part part)
|
||||
{
|
||||
var perimeter = Profile(part).Perimeter;
|
||||
@@ -275,10 +273,4 @@ public class PerimeterCornerLeadInTests
|
||||
|
||||
private static Line SingleLead(Part part, Layer layer) => Assert.IsType<Line>(Assert.Single(
|
||||
part.Program.ToGeometry().Where(e => e.Layer == layer)));
|
||||
|
||||
private static void AssertPoint(Vector expected, Vector actual)
|
||||
{
|
||||
Assert.Equal(expected.X, actual.X, 8);
|
||||
Assert.Equal(expected.Y, actual.Y, 8);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user