Conversation
| new object[] { "+1,-1", "+1,+1", "3,0", 2.0 }, | ||
| }; | ||
|
|
||
| [TestCaseSource(nameof(DistanceTestCases))] |
There was a problem hiding this comment.
I think the previous structure with TestCase was much better. My suggestion with the swapped scenarios was meant to be handled in the TestCase definition, not as a separate test function.
There was a problem hiding this comment.
Thanks for the comment.
Could you tell me why using TestCode is better than using TestCodeSource for this test?
There was a problem hiding this comment.
I find the whole new object[] a bit overkill, that's it. I guess it's more a matter of personal taste.
There was a problem hiding this comment.
Thanks for the comment.
it's more a matter of personal taste.
Could you show the reason?
There was a problem hiding this comment.
The reason for what exactly? I prefer compile-time checks and try to avoid object as much as possible
There was a problem hiding this comment.
Thanks for telling the reasons.
Done in the commit cd80cf1.
I changed the test-code as you required. I'm not sure that the revised test-code helps the reader understand at a glance that parameters are kept intact except its order.
There was a problem hiding this comment.
Thank you. This is not what I meant, we can augment the existing tests with a reversed line
var line = new Line2D(Point2D.Parse(p1s), Point2D.Parse(p2s));
// existing test
var reversedLine = new Line2D(Point2D.Parse(p2s), Point2D.Parse(p1s));
// distance test with reversed line
This way you keep the TestCase cases at a minimum
There was a problem hiding this comment.
Thanks for showing the example closely.
It is not recommended to test 2 things in a single unit-test.
Or do you want to say that these 2 tests are equivalent because of the symmetry?
There was a problem hiding this comment.
It is not recommended to test 2 things in a single unit-test.
Fully agree
Or do you want to say that these 2 tests are equivalent because of the symmetry?
Basically yes
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the straight line Distance to the given point. |
There was a problem hiding this comment.
I would describe this as 'Returns the length of the perpendicular line to the given point.'
I implemented
Line2D.DistanceTo(Point2D p)which calculates the distance fromthisline to the given pointp.This method should always return the value of 0 or positive.
It will be nice if we can discuss whether the testcases is sufficient.