mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 06:41:42 -05:00
Moves the Drawings tab's row content (quantity, size, area, highlight and quantity bar, the hidden-list note), Delete Drawing, Remove Unused Drawings and the Drawing Properties dialog's values and color rules into OpenNest.Desktop so the Avalonia app can share them. The WinForms list, nest window and Edit Drawing form delegate to them unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
2.5 KiB
C#
82 lines
2.5 KiB
C#
namespace OpenNest.Desktop.Tests.Drawings;
|
|
|
|
public class DrawingListRowTests
|
|
{
|
|
private static (Nest Nest, Drawing Drawing) Nested(int required)
|
|
{
|
|
var nest = TestNests.OneSquare();
|
|
var drawing = nest.Drawings.First();
|
|
drawing.Quantity.Required = required;
|
|
nest.Plates[0].Quantity = 1;
|
|
nest.UpdateDrawingQuantities();
|
|
return (nest, drawing);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShowsTheNameQuantitySizeAndArea()
|
|
{
|
|
var (_, drawing) = Nested(3);
|
|
|
|
var row = DrawingListRow.For(drawing, plate: null, Units.Inches);
|
|
|
|
Assert.Same(drawing, row.Drawing);
|
|
Assert.Equal("square", row.Name);
|
|
Assert.Equal("1 of 3 nested", row.Quantity);
|
|
Assert.Equal("10 x 10", row.Size);
|
|
Assert.Equal("100 sq/in", row.Area);
|
|
Assert.False(row.IsHighlighted);
|
|
Assert.Equal(DrawingQuantityBar.Short, row.Bar);
|
|
}
|
|
|
|
[Fact]
|
|
public void PrefixesTheCountOnTheShownPlate()
|
|
{
|
|
var (nest, drawing) = Nested(3);
|
|
|
|
Assert.Equal("[1] 1 of 3 nested", DrawingListRow.For(drawing, nest.Plates[0], Units.Inches).Quantity);
|
|
Assert.Equal("1 of 3 nested", DrawingListRow.For(drawing, new Plate(), Units.Inches).Quantity);
|
|
}
|
|
|
|
[Fact]
|
|
public void AllNested_IsHighlightedWithACompleteBar()
|
|
{
|
|
var (_, drawing) = Nested(1);
|
|
|
|
var row = DrawingListRow.For(drawing, null, Units.Millimeters);
|
|
|
|
Assert.True(row.IsHighlighted);
|
|
Assert.Equal(DrawingQuantityBar.Complete, row.Bar);
|
|
Assert.Equal("100 sq/mm", row.Area);
|
|
}
|
|
|
|
[Fact]
|
|
public void NoRequiredQuantity_HasNoBar_ButNestedPartsHighlight()
|
|
{
|
|
var (_, drawing) = Nested(0);
|
|
|
|
var row = DrawingListRow.For(drawing, null, Units.Inches);
|
|
|
|
Assert.Equal(DrawingQuantityBar.None, row.Bar);
|
|
Assert.True(row.IsHighlighted);
|
|
}
|
|
|
|
[Fact]
|
|
public void HiddenQuantity_LeavesOutTheQuantityHighlightAndBar()
|
|
{
|
|
var (_, drawing) = Nested(1);
|
|
|
|
var row = DrawingListRow.For(drawing, null, Units.Inches, hideQuantity: true);
|
|
|
|
Assert.Null(row.Quantity);
|
|
Assert.False(row.IsHighlighted);
|
|
Assert.Equal(DrawingQuantityBar.None, row.Bar);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(true, 2, DrawingListRow.AllHiddenText)]
|
|
[InlineData(true, 0, null)]
|
|
[InlineData(false, 2, null)]
|
|
public void EmptyText_ExplainsOnlyAListTheFilterEmptied(bool hide, int drawings, string expected) =>
|
|
Assert.Equal(expected, DrawingListRow.EmptyText(hide, drawings));
|
|
}
|