haplokuon / netDxf

.net dxf Reader-Writer
MIT License
1.01k stars 411 forks source link

net6 unit tests framework #397

Closed devel0 closed 2 years ago

devel0 commented 2 years ago

This PR adds unit test framework and NET6 targeting. In the first unit test inserted I test for Arc StartAngle, EndAngle and with the given dxf Polyline2DTest_0001.dxf results that test fails.

how test values given

If you try to explode the polyline in the dxf youll'notice that start point is marked with red and end point is marked with blue ( I used qcad ) ; aside there is Start Angle and End Angle values that I copied into the unit test ( mine qcad set with 8 decimals so testing tol=1e-8 ).

image

how to run test

image

why test fails

the test expects StartAngle ~= 214 while EndAngle ~= 210 for the first arc coming from the lwp explosion ( the one selected in the first sshoot ) ; this is because the order of polyline vertexes is following

image

then the polyline explosion generates LINE , ARC , LINE , ARC , LINE , ARC , LINE , ARC where the first ARC requires that StartAngle is ~214 and EndAngle ~210 so this implies that StartAngle isn't necessary less than EndAngle in general.

unit tests

I hope youll'find the unit test system somewhat useful, personally I can't work without, they help me to double check automatically every function I wrote and they are really helpful for any refactoring because what is already written will ever need to satisfy conditions imposed by test and when you run dotnet test youll'see if something doesn't fit any more with what previously stated as correct. In other words unit test acts like a barrier for errors ( of course the test need to be constructed as a valid check ).

devel0 commented 2 years ago

I added a fix to the unit test relates to PR https://github.com/haplokuon/netDxf/pull/398#issuecomment-1207200051