Files
OpenNest/OpenNest.Tests/Engine/ExplicitPlacementStrategyTests.cs
T
ajandClaude Opus 5.5 bdd6625713 test: share the rectangle drawing fixture
Thirteen test classes built the same origin-anchored rectangle drawing in
their own private helper (MakeRectDrawing, MakeRect or Rect). They now
call TestHelpers.MakeRectDrawing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:21:27 -05:00

68 lines
2.0 KiB
C#

using OpenNest.CNC;
using OpenNest.Engine;
using OpenNest.Engine.Jobs.Placement;
using OpenNest.Geometry;
namespace OpenNest.Tests.Engine;
/// <summary>
/// Callers name the placement strategy explicitly at the <see cref="PlateFillService"/>
/// boundary instead of consulting process-global selection state.
/// </summary>
public class ExplicitPlacementStrategyTests
{
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void ResolveStrategy_UnsetMeansFill(string strategy)
{
Assert.Equal("Fill", PlateFillService.ResolveStrategy(strategy));
}
[Theory]
[InlineData("strip", "Strip")]
[InlineData("VERTICAL REMNANT", "Vertical Remnant")]
public void ResolveStrategy_ReturnsCanonicalBuiltInName(string strategy, string expected)
{
Assert.Equal(expected, PlateFillService.ResolveStrategy(strategy));
}
[Theory]
[InlineData("Mystery Engine")]
[InlineData("StockLadder")]
public void ResolveStrategy_RejectsUnknownStrategy(string strategy)
{
Assert.Throws<NotSupportedException>(() => PlateFillService.ResolveStrategy(strategy));
}
[Fact]
public void PlateFillService_Nest_ResolvesNamedStrategyAndRejectsUnknown()
{
var plate = new Plate(new Size(60, 80));
var drawing = TestHelpers.MakeRectDrawing(6, 4, "part");
var parts = PlateFillService.Nest(
"Vertical Remnant",
plate,
new List<NestItem> { new() { Drawing = drawing, Quantity = 4 } },
null,
CancellationToken.None
);
Assert.NotEmpty(parts);
Assert.All(parts, part => Assert.Same(drawing, part.BaseDrawing));
Assert.Empty(plate.Parts);
Assert.Throws<NotSupportedException>(() =>
PlateFillService.Nest(
"Mystery Engine",
plate,
new List<NestItem> { new() { Drawing = drawing, Quantity = 1 } },
null,
CancellationToken.None
)
);
}
}