Files
OpenNest/OpenNest.Tests/Fill/AccumulatingProgressTests.cs
T
aj aec0523062 style: apply CSharpier formatting to all C# sources
Repo-wide sweep with the pinned CSharpier 1.3.0 tool. Whitespace and
line-wrapping only; OpenNest.Engine.Tests (109) and OpenNest.IO.Tests
pass after reformat, full solution builds 0 errors.

Added .csharpierignore so csproj/config XML keeps its existing layout
(CSharpier's XML wrapping churns attributes with zero benefit).

Formatting is now enforceable: dotnet csharpier check . passes.
2026-09-20 16:41:50 -04:00

55 lines
1.7 KiB
C#

using OpenNest.Engine.Fill;
namespace OpenNest.Tests.Fill;
public class AccumulatingProgressTests
{
private class CapturingProgress : IProgress<NestProgress>
{
public NestProgress Last { get; private set; }
public void Report(NestProgress value) => Last = value;
}
[Fact]
public void Report_PrependsPreviousParts()
{
var inner = new CapturingProgress();
var previous = new List<Part> { TestHelpers.MakePartAt(0, 0, 10) };
var accumulating = new AccumulatingProgress(inner, previous);
var newParts = new List<Part> { TestHelpers.MakePartAt(20, 0, 10) };
accumulating.Report(new NestProgress { BestParts = newParts });
Assert.NotNull(inner.Last);
Assert.Equal(2, inner.Last.BestParts.Count);
Assert.Equal(2, inner.Last.BestPartCount);
}
[Fact]
public void Report_NoPreviousParts_PassesThrough()
{
var inner = new CapturingProgress();
var accumulating = new AccumulatingProgress(inner, new List<Part>());
var newParts = new List<Part> { TestHelpers.MakePartAt(0, 0, 10) };
accumulating.Report(new NestProgress { BestParts = newParts });
Assert.NotNull(inner.Last);
Assert.Single(inner.Last.BestParts);
}
[Fact]
public void Report_NullBestParts_PassesThrough()
{
var inner = new CapturingProgress();
var previous = new List<Part> { TestHelpers.MakePartAt(0, 0, 10) };
var accumulating = new AccumulatingProgress(inner, previous);
accumulating.Report(new NestProgress { BestParts = null });
Assert.NotNull(inner.Last);
Assert.Null(inner.Last.BestParts);
}
}