@@ -79,31 +79,45 @@ public void CircleIntersectWithLine2D_NumberOfIntersections(string sc, double ra
7979 }
8080
8181 //segment contains the all intersections(same to the cases of circle and line)
82- [ TestCase ( "0,0" , 1 , "-10,+10" , "+10,+10" , 0 ) ]
83- [ TestCase ( "0,0" , 1 , "-10,+1" , "+10,+1" , 1 ) ]
84- [ TestCase ( "0,0" , 1 , "-10,0" , "+10,0" , 2 ) ]
85- [ TestCase ( "0,0" , 1 , "-10,-1" , "+10,-1" , 1 ) ]
86- [ TestCase ( "0,0" , 1 , "-10,-10" , "+10,-10" , 0 ) ]
82+ [ TestCase ( "0,0" , 1 , "-10,+10" , "+10,+10" , "empty" ) ]
83+ [ TestCase ( "0,0" , 1 , "-10,+1" , "+10,+1" , "0,+1" ) ]
84+ [ TestCase ( "0,0" , 1 , "-10,0" , "+10,0" , "-1,0;+1,0" ) ]
85+ [ TestCase ( "0,0" , 1 , "-10,-1" , "+10,-1" , "0,-1" ) ]
86+ [ TestCase ( "0,0" , 1 , "-10,-10" , "+10,-10" , "empty" ) ]
8787 //segments cross the circle's contour just 1 time
88- [ TestCase ( "0,0" , 1 , "+0,+10" , "+10,+10" , 0 ) ]
89- [ TestCase ( "0,0" , 1 , "+0,+1" , "+10,+1" , 1 ) ]
90- [ TestCase ( "0,0" , 1 , "+0,0" , "+10,0" , 1 ) ]
91- [ TestCase ( "0,0" , 1 , "+0,-1" , "+10,-1" , 1 ) ]
92- [ TestCase ( "0,0" , 1 , "+0,-10" , "+10,-10" , 0 ) ]
88+ [ TestCase ( "0,0" , 1 , "+0,+10" , "+10,+10" , "empty" ) ]
89+ [ TestCase ( "0,0" , 1 , "+0,+1" , "+10,+1" , "0,1" ) ]
90+ [ TestCase ( "0,0" , 1 , "+0,0" , "+10,0" , "1,0" ) ]
91+ [ TestCase ( "0,0" , 1 , "+0,-1" , "+10,-1" , "0,-1" ) ]
92+ [ TestCase ( "0,0" , 1 , "+0,-10" , "+10,-10" , "empty" ) ]
9393 //segment contains no intersections(px of the startingPoint is too big to intersect with the circle)
94- [ TestCase ( "0,0" , 1 , "+10,+10" , "+100,+10" , 0 ) ]
95- [ TestCase ( "0,0" , 1 , "+10,+01" , "+100,+1" , 0 ) ]
96- [ TestCase ( "0,0" , 1 , "+10,+00" , "+100,0" , 0 ) ]
97- [ TestCase ( "0,0" , 1 , "+10,-01" , "+100,-1" , 0 ) ]
98- [ TestCase ( "0,0" , 1 , "+10,-10" , "+100,-10" , 0 ) ]
99- public void CircleIntersectWithLineSegment2D_NumberOfIntersections ( string sCenter , double radius , string sStart , string sEnd , int expectedNumberOfIntersections )
94+ [ TestCase ( "0,0" , 1 , "+10,+10" , "+100,+10" , "empty" ) ]
95+ [ TestCase ( "0,0" , 1 , "+10,+01" , "+100,+1" , "empty" ) ]
96+ [ TestCase ( "0,0" , 1 , "+10,+00" , "+100,0" , "empty" ) ]
97+ [ TestCase ( "0,0" , 1 , "+10,-01" , "+100,-1" , "empty" ) ]
98+ [ TestCase ( "0,0" , 1 , "+10,-10" , "+100,-10" , "empty" ) ]
99+ public void CircleIntersectWithLineSegment2D_NumberOfIntersections ( string sCenter , double radius , string sStart , string sEnd , string expectedIntersectionsAsString )
100100 {
101101 var circle = new Circle2D ( Point2D . Parse ( sCenter ) , radius ) ;
102102 var segment = new LineSegment2D ( Point2D . Parse ( sStart ) , Point2D . Parse ( sEnd ) ) ;
103103
104104 var actual = circle . IntersectWith ( segment ) ;
105105
106- Assert . That ( actual . Count ( ) , Is . EqualTo ( expectedNumberOfIntersections ) ) ;
106+ var expected = parseToPointsArray ( expectedIntersectionsAsString ) ;
107+ CollectionAssert . AreEquivalent ( expected , actual ) ;
108+ }
109+
110+ private Point2D [ ] parseToPointsArray ( string input )
111+ {
112+ if ( input . ToLower ( ) . Contains ( "empty" ) )
113+ {
114+ return new Point2D [ ] { } ;
115+ }
116+
117+ var result = input . Split ( ';' )
118+ . Select ( s => Point2D . Parse ( s ) )
119+ . ToArray ( ) ;
120+ return result ;
107121 }
108122 }
109123}
0 commit comments