test(frontend): share the in-process console runner

Three front-end test classes ran NestConsole.Run through their own
reflection helper. They now import ConsoleHost.RunConsole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-01 11:23:01 -05:00
1 parent 9d6d5fa4b2
commit 658b3552c1
4 files changed
+18 -21

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
using System.Reflection;
namespace OpenNest.FrontEnd.Tests;
/// <summary>Runs the console front end in-process. Import with <c>using static</c>.</summary>
internal static class ConsoleHost
{
/// <summary>Calls <c>NestConsole.Run</c> and returns its exit code.</summary>
public static int RunConsole(params string[] args)
{
var method = Assembly.Load("OpenNest.Console").GetType("NestConsole")!
.GetMethod("Run", BindingFlags.Static | BindingFlags.Public)!;
return (int)method.Invoke(null, new object[] { args })!;
}
}
@@ -5,6 +5,7 @@ using OpenNest.Geometry;
using OpenNest.IO;
using OpenNest.Mcp;
using OpenNest.Mcp.Tools;
using static OpenNest.FrontEnd.Tests.ConsoleHost;
namespace OpenNest.FrontEnd.Tests;
@@ -171,13 +172,6 @@ public class CuttingPlanFrontEndTests : IDisposable
Assert.False(part.HasManualLeadIns);
}
private static int RunConsole(params string[] args)
{
var method = Assembly.Load("OpenNest.Console").GetType("NestConsole")!
.GetMethod("Run", BindingFlags.Static | BindingFlags.Public)!;
return (int)method.Invoke(null, new object[] { args })!;
}
private static Nest Fixture(Program program, params Vector[] locations)
{
var nest = new Nest("fixture");
@@ -6,6 +6,7 @@ using OpenNest.Geometry;
using OpenNest.IO;
using OpenNest.Mcp;
using OpenNest.Mcp.Tools;
using static OpenNest.FrontEnd.Tests.ConsoleHost;
namespace OpenNest.FrontEnd.Tests;
@@ -75,13 +76,6 @@ public class NestingPipelineTests : IDisposable
new[] { new StockUsage(job.Plates[0].Id, 999, 0) });
}
private static int RunConsole(params string[] args)
{
var method = Assembly.Load("OpenNest.Console").GetType("NestConsole")!
.GetMethod("Run", BindingFlags.Static | BindingFlags.Public)!;
return (int)method.Invoke(null, new object[] { args })!;
}
[Theory]
[InlineData("overlap", false, 2)]
[InlineData("overlap", true, 0)]
@@ -11,6 +11,7 @@ using OpenNest.Geometry;
using OpenNest.IO.Bending;
using OpenNest.Mcp;
using OpenNest.Mcp.Tools;
using static OpenNest.FrontEnd.Tests.ConsoleHost;
using CadLayer = ACadSharp.Tables.Layer;
using CadLine = ACadSharp.Entities.Line;
@@ -136,13 +137,6 @@ public class RegexImportFailureTests : IDisposable
Assert.Equal(hash, Hash(bad));
}
private static int RunConsole(params string[] args)
{
var method = Assembly.Load("OpenNest.Console").GetType("NestConsole")!
.GetMethod("Run", BindingFlags.Static | BindingFlags.Public)!;
return (int)method.Invoke(null, new object[] { args })!;
}
private string WriteDxf(string name, bool marker)
{
var document = new CadDocument();