Console --engine now names a jobs engine for --autonest (solved once through NestingEngineRegistry.Create and committed onto the plate) or a built-in fill strategy for single-plate fill through the public PlateFillService; unknown names exit with the valid choices instead of consulting the process-global legacy registry. MCP nesting tools take an explicit engine argument per call with the session default, never read process-global active-engine state, and reject whole-job engine names on single-plate fill tools. NestingEngineRegistry gains an explicit Create (name) resolution; PlateFillService gains a public ResolveStrategy and a plate-number Nest overload used by interactive callers.
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using Xunit;
|
|
using OpenNest.Engine.Jobs;
|
|
|
|
namespace OpenNest.Engine.Tests.Jobs;
|
|
|
|
public class NestingEngineRegistryTests
|
|
{
|
|
[Fact]
|
|
public void BuiltInStrategiesAreRegistered()
|
|
{
|
|
var names = NestingEngineRegistry.AvailableEngines.Select(e => e.Name).ToList();
|
|
|
|
Assert.Contains("Default", names);
|
|
Assert.Contains("Strip", names);
|
|
Assert.Contains("Vertical Remnant", names);
|
|
Assert.Contains("Horizontal Remnant", names);
|
|
}
|
|
|
|
[Fact]
|
|
public void EachBuiltInFactoryProducesAWorkingEngine()
|
|
{
|
|
foreach (var info in NestingEngineRegistry.AvailableEngines)
|
|
{
|
|
var engine = info.Factory();
|
|
var result = engine.Solve(FiniteStockJobTests.Job(1));
|
|
|
|
Assert.Equal(NestJobStatus.Complete, result.Status);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void DuplicateNameIsSkipped()
|
|
{
|
|
var before = NestingEngineRegistry.AvailableEngines.Count;
|
|
|
|
NestingEngineRegistry.Register(
|
|
"Default",
|
|
"duplicate",
|
|
() => new FixedStrategyNestingEngine("Default")
|
|
);
|
|
|
|
Assert.Equal(before, NestingEngineRegistry.AvailableEngines.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void CreateResolvesKnownNamesCaseInsensitivelyAndRejectsUnknown()
|
|
{
|
|
Assert.NotNull(NestingEngineRegistry.Create("default"));
|
|
Assert.NotNull(NestingEngineRegistry.Create("Vertical Remnant"));
|
|
Assert.NotNull(NestingEngineRegistry.Create("stockladder"));
|
|
|
|
Assert.Throws<NotSupportedException>(() => NestingEngineRegistry.Create("Mystery Engine"));
|
|
Assert.Throws<ArgumentException>(() => NestingEngineRegistry.Create(" "));
|
|
Assert.Throws<ArgumentNullException>(() => NestingEngineRegistry.Create(null!));
|
|
}
|
|
|
|
[Fact]
|
|
public void CreateProducesAWorkingEngine()
|
|
{
|
|
var engine = NestingEngineRegistry.Create("Strip");
|
|
var result = engine.Solve(FiniteStockJobTests.Job(1));
|
|
|
|
Assert.Equal(NestJobStatus.Complete, result.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void LoadPluginsAgainstMissingDirectoryIsANoOp()
|
|
{
|
|
var before = NestingEngineRegistry.AvailableEngines.Count;
|
|
|
|
NestingEngineRegistry.LoadPlugins(
|
|
Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())
|
|
);
|
|
|
|
Assert.Equal(before, NestingEngineRegistry.AvailableEngines.Count);
|
|
}
|
|
}
|