feat: add xUnit test project with fill and remnant fill tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 21:07:04 -04:00
parent d2a71a6d8c
commit 8fcd3660d8
5 changed files with 258 additions and 0 deletions

64
TestData.cs Normal file
View File

@@ -0,0 +1,64 @@
using OpenNest.IO;
namespace OpenNest.Test;
public static class TestData
{
private static readonly string? BasePath = ResolveBasePath();
public static bool IsAvailable => BasePath != null;
public static string SkipReason =>
"Test data not found. Fixture .zip files should be in the repo root.";
public static string GetPath(string filename)
{
if (BasePath == null)
throw new InvalidOperationException(SkipReason);
var path = Path.Combine(BasePath, filename);
if (!File.Exists(path))
throw new FileNotFoundException($"Test fixture not found: {path}");
return path;
}
public static Nest LoadNest(string filename)
{
var reader = new NestReader(GetPath(filename));
return reader.Read();
}
public static Plate CleanPlateFrom(Plate reference)
{
var plate = new Plate();
plate.Size = reference.Size;
plate.PartSpacing = reference.PartSpacing;
plate.EdgeSpacing = reference.EdgeSpacing;
plate.Quadrant = reference.Quadrant;
return plate;
}
private static string? ResolveBasePath()
{
// Walk up from bin/Debug/net8.0-windows to find the repo root
// (where the .zip fixture files live alongside the csproj).
var dir = AppContext.BaseDirectory;
for (var i = 0; i < 6; i++)
{
var parent = Directory.GetParent(dir);
if (parent == null)
break;
dir = parent.FullName;
if (File.Exists(Path.Combine(dir, "OpenNest.Test.csproj")))
return dir;
}
return null;
}
}