netDxf icon indicating copy to clipboard operation
netDxf copied to clipboard

net6 unit tests framework

Open devel0 opened this issue 1 year ago • 1 comments

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

  • first of all install net6 sdk ( https://dotnet.microsoft.com/en-us/download )
  • from command line run dotnet 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 avatar Aug 06 '22 00:08 devel0

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

devel0 avatar Aug 06 '22 12:08 devel0