mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-07 07:52:11 -04:00
A BOM row with a file name and a matching drawing but a blank thickness was reported "No DXF" and locked, so its thickness could not be entered and the part was dropped: BomAnalyzer skips such items before looking for a drawing, and the form only knew drawings the analyzer matched. A row with a blank material read "Matched" but was silently left out of every group. Rows now resolve their drawing through a DrawingFileIndex shared with BomAnalyzer (whose behavior and tests are unchanged), and a row's status is computed from its values: Ready | Needs material | Needs thickness | No drawing found | No file name Rows with a drawing stay editable, and an edit updates the status cell. Groups take only Ready rows (a zero, negative or non-finite thickness is not Ready). The summary line counts ready rows and each problem. Build_RowWithoutThickness_StillFindsItsDrawing failed at its DxfPath assertion against the previous commit. Mutation reds: removing the material check, accepting zero or non-finite thickness, skipping the drawing for rows without thickness, and grouping without the status each fail the Bom tests. Project Memory: b8e3a978-2cfe-4fe7-b2a5-eb01c6c54679
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using OpenNest.IO.Bom;
|
|
|
|
namespace OpenNest.Tests.Bom;
|
|
|
|
public class BomPartRowTests
|
|
{
|
|
[Theory]
|
|
[InlineData(null, "/d/PT01.dxf", "Steel", 0.25, BomRowStatus.NoFileName)]
|
|
[InlineData(" ", "/d/PT01.dxf", "Steel", 0.25, BomRowStatus.NoFileName)]
|
|
[InlineData("PT01", null, "Steel", 0.25, BomRowStatus.NoDrawing)]
|
|
[InlineData("PT01", "/d/PT01.dxf", null, 0.25, BomRowStatus.NeedsMaterial)]
|
|
[InlineData("PT01", "/d/PT01.dxf", "\t", 0.25, BomRowStatus.NeedsMaterial)]
|
|
[InlineData("PT01", "/d/PT01.dxf", "Steel", null, BomRowStatus.NeedsThickness)]
|
|
[InlineData("PT01", "/d/PT01.dxf", "Steel", 0.0, BomRowStatus.NeedsThickness)]
|
|
[InlineData("PT01", "/d/PT01.dxf", "Steel", -0.25, BomRowStatus.NeedsThickness)]
|
|
[InlineData("PT01", "/d/PT01.dxf", "Steel", double.NaN, BomRowStatus.NeedsThickness)]
|
|
[InlineData("PT01", "/d/PT01.dxf", "Steel", double.PositiveInfinity, BomRowStatus.NeedsThickness)]
|
|
[InlineData("PT01", "/d/PT01.dxf", "Steel", 0.25, BomRowStatus.Ready)]
|
|
public void Status_FollowsTheFirstMissingValue(
|
|
string? fileName,
|
|
string? dxfPath,
|
|
string? material,
|
|
double? thickness,
|
|
BomRowStatus expected
|
|
)
|
|
{
|
|
var row = new BomPartRow
|
|
{
|
|
FileName = fileName,
|
|
DxfPath = dxfPath,
|
|
Material = material,
|
|
Thickness = thickness,
|
|
};
|
|
|
|
Assert.Equal(expected, row.Status);
|
|
Assert.Equal(expected is not (BomRowStatus.NoFileName or BomRowStatus.NoDrawing), row.IsEditable);
|
|
}
|
|
|
|
[Fact]
|
|
public void Status_ChangesWhenTheOperatorFillsInAValue()
|
|
{
|
|
var row = new BomPartRow { FileName = "PT01", DxfPath = "/d/PT01.dxf" };
|
|
Assert.Equal(BomRowStatus.NeedsMaterial, row.Status);
|
|
|
|
row.Material = "Steel";
|
|
Assert.Equal(BomRowStatus.NeedsThickness, row.Status);
|
|
|
|
row.Thickness = 0.25;
|
|
Assert.Equal(BomRowStatus.Ready, row.Status);
|
|
Assert.Equal("Ready", row.StatusText);
|
|
}
|
|
|
|
[Fact]
|
|
public void Describe_NamesEveryStatus()
|
|
{
|
|
Assert.Equal(
|
|
new[] { "Ready", "Needs material", "Needs thickness", "No drawing found", "No file name" },
|
|
Enum.GetValues<BomRowStatus>().Select(BomPartRow.Describe)
|
|
);
|
|
}
|
|
}
|