Add AssertRoundtrip for custom roundtrip test assertions - #1256
Merged
Merged
Conversation
Introduce AssertRoundtrip property to SingleCaseGenerator, enabling custom assertions on CadDocument after roundtrip operations. Update SingleLine test to use this mechanism and invoke it in DwgWriterSingleObjectTests, allowing more flexible and targeted validation in tests.
Replaces flat SegmentIndex/StartEndPointPairs in LeaderLine with a BreakInfo class and a list of BreakInfo entries. Updates reading, writing, cloning, and document assignment logic to support multiple break info entries per leader line, improving structure and clarity.
Set default values for key MultiLeader and MultiLeaderObjectContextData properties to ensure valid initial states. Refactor LeaderContentType enum for clarity. Update DwgObjectReader to use _mergedReaders for color reading. Simplify DwgObjectWriter logic for writing leader roots and annotation context data. Perform minor code cleanup.
Add conditional logic for R2007Pre arrowhead handling in DwgObjectWriter. Refactor CadMLeaderTemplate for clarity: mark as internal, improve formatting, streamline constructors and build method, and clarify attribute handle resolution. Add placeholder for ArrowheadHandles processing.
Made CadDictionaryTemplate public, refactored constructors, and improved the build method for better root dictionary handling, entry resolution, and error notifications. Cleaned up redundant code for clarity.
Refactored the iteration over dictionary entries to use a for loop with EntryHandles and EntryNames arrays instead of foreach. This ensures correct pairing of handles and names, and updates all related logic to use the new approach for improved consistency and reliability.
Introduce AssertRoundtrip lambdas in test methods to verify round-trip serialization/deserialization of CAD objects. Refactor tests to use local variables for entity handles, ensuring consistent and thorough validation of object equality and collection counts across the test suite. This standardizes and improves test reliability.
Refactored the Transparency struct with improved XML docs, property accessors, and validation logic. Enhanced FromAlphaValue and ToAlphaValue methods for clarity. Updated WriterSingleObjectTests to skip unsupported assertions for older ACad versions and set CodePage for Chinese text tests.
Explicitly set HasTextContents to true after assigning the TextLabel property, ensuring the MultiLeader context data correctly reflects the presence of text contents. No other logic was changed.
Refactored DwgObjectWriter to use EntryHandles/EntryNames for accurate dictionary entry association and writing. Improved WriterSingleObjectTests to assert SpatialFilter presence and boundary point preservation after roundtrip. Added System.ComponentModel using directive.
Add version check in AssertRoundtrip to bypass MText comparison for AC1018 (R2000) and earlier, as MText encoding is not supported in those versions. Also add System.Diagnostics using directive.
Add optional roundtrip assertion via AssertRoundtrip in DxfWriterSingleObjectTests. Replace single entity assertion in WriterSingleObjectTests with checks for correct entity ownership and matching PaperSpace entity counts.
Introduce Format property to WriterSingleObjectTests for distinguishing DWG and DXF formats. Update roundtrip assertions to account for format and version-specific behavior, skipping unsupported checks for DXF and older versions. Import ACadSharp.IO namespace.
Updated WriterSingleObjectTests to skip color equality checks for layers in unsupported DWG versions. Removed ClipBoundaryVertices count assertions in raster and wipeout tests. DxfSectionWriterBase now writes clip boundary vertices unconditionally, regardless of clip type.
Renamed LineType in test to "LTYPE_PAINT" for consistency. Added serialization of LineType, LineTypeExt1, and LineTypeExt2 handles (group codes 345-347) in DxfTablesSectionWriter for DimensionStyle.
Changed LineType name from "LTYPE:PAINT" to "LTYPE_PAINT" for consistency. Added a conditional to skip mesh roundtrip assertions when the file format is DXF.
Added logic to read and set CloningFlags from group code 280 in readXRecordEntries before processing other XRecord data. This ensures proper handling of dictionary cloning flags during DXF object parsing.
Introduce BreakInfo with deep clone support and XML docs. Refactor LeaderLine to improve cloning and documentation, moving BreakInfoEntries and ensuring deep copies. Refactor StartEndPointPair as a top-level struct with better docs, a constructor, and a Clone method. Remove redundant code from old LeaderLine.Clone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce AssertRoundtrip property to SingleCaseGenerator, enabling custom assertions on CadDocument after roundtrip operations.
Update SingleLine test to use this mechanism and invoke it in DwgWriterSingleObjectTests, allowing more flexible and targeted validation in tests.