mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-27 03:51:05 -04:00
Library drawings travel as a single-drawing, zero-plate .nest archive so the server stores opaque bytes and the client reuses NestWriter/NestReader. A characterization test first proves that shape round-trips the program, hole programs, source entities and suppression, offset, material, bends and units. Packages are canonical: fixed archive and nest timestamps, zero nest quantity and no best-fit caches. The same drawing content therefore has the same bytes and SHA-256, which later revision checks rely on to tell geometry changes from detail-only edits. Read checks the archive's own declaration before the lenient nest reader, which would otherwise default unknown units and drop empty plates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
2.1 KiB
C#
46 lines
2.1 KiB
C#
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.IO.Tests;
|
|
|
|
/// <summary>
|
|
/// Characterizes a single-drawing, zero-plate .nest archive through the unchanged
|
|
/// writer and reader, which drawing packages rely on.
|
|
/// </summary>
|
|
public class ZeroPlateNestTests
|
|
{
|
|
[Fact]
|
|
public void SingleDrawingWithoutPlates_RoundTripsTheDrawing()
|
|
{
|
|
var drawing = DrawingPackageFixture.Build();
|
|
var nest = new Nest(drawing.Name) { Units = Units.Millimeters };
|
|
nest.Drawings.Add(drawing);
|
|
using var stream = new MemoryStream();
|
|
|
|
Assert.True(new NestWriter(nest).Write(stream));
|
|
stream.Position = 0;
|
|
var reader = new NestReader(stream);
|
|
var restored = reader.Read();
|
|
|
|
Assert.Empty(reader.Warnings);
|
|
Assert.Empty(restored.Plates);
|
|
Assert.Equal(Units.Millimeters, restored.Units);
|
|
var copy = Assert.Single(restored.Drawings);
|
|
Assert.Equal(NestWriter.GetProgramText(drawing.Program), NestWriter.GetProgramText(copy.Program));
|
|
Assert.Equal(NestWriter.GetSubProgramsText(drawing.Program), NestWriter.GetSubProgramsText(copy.Program));
|
|
Assert.Equal(drawing.Name, copy.Name);
|
|
Assert.Equal(drawing.Customer, copy.Customer);
|
|
Assert.Equal((drawing.Material.Name, drawing.Material.Grade, drawing.Material.Density),
|
|
(copy.Material.Name, copy.Material.Grade, copy.Material.Density));
|
|
Assert.Equal(drawing.Priority, copy.Priority);
|
|
Assert.Equal(drawing.Quantity.Required, copy.Quantity.Required);
|
|
Assert.Equal(drawing.Source.Path, copy.Source.Path);
|
|
Assert.Equal(drawing.Source.Offset, copy.Source.Offset);
|
|
Assert.Equal(drawing.SourceEntities.Select(e => (e.Id, e.Type, e.Layer?.Name)),
|
|
copy.SourceEntities.Select(e => (e.Id, e.Type, e.Layer?.Name)));
|
|
Assert.True(drawing.SuppressedEntityIds.SetEquals(copy.SuppressedEntityIds));
|
|
var bend = Assert.Single(copy.Bends);
|
|
Assert.Equal((new Vector(0, 3), new Vector(10, 3), (double?)90, (double?)0.125, "UP 90"),
|
|
(bend.StartPoint, bend.EndPoint, bend.Angle, bend.Radius, bend.NoteText));
|
|
}
|
|
}
|