Skip to content

Commit 7c5df6a

Browse files
committed
test: fix testcases to test number of intersections
1 parent 9e33c1b commit 7c5df6a

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/Spatial.Tests/Euclidean/Circle2DTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using System;
2+
using System.Linq;
23
using MathNet.Spatial.Euclidean;
34
using NUnit.Framework;
45

@@ -59,19 +60,19 @@ public void CircleFromThreePointsArgumentException()
5960
Assert.Throws<ArgumentException>(() => { Circle2D.FromPoints(p1, p2, p3); });
6061
}
6162

62-
[TestCase("0,0", 1.41421356 /*=sqrt(2)*/, "-1,-1", "+1,+1", "+1,+1", "-1,-1")]
63-
[TestCase("0,0", 1, "-1,0", "+1,0", "+1,0", "-1,0")]
64-
[TestCase("0,0", 1, "0,-1", "0,+1", "0,+1", "0,-1")]
65-
public void CircleIntersectWithLine2D(string sc, double radius, string sps, string spe, string esp0, string esp1)
63+
[TestCase("0,0", 1, "-10,+10", "+10,+10", 0)]
64+
[TestCase("0,0", 1, "-10,+1", "+10,+1", 1)]
65+
[TestCase("0,0", 1, "-10,0", "+10,0", 2)]
66+
[TestCase("0,0", 1, "-10,-1", "+10,-1", 1 )]
67+
[TestCase("0,0", 1, "-10,-10", "+10,-10", 0)]
68+
public void CircleIntersectWithLine2D_NumberOfIntersections(string sc, double radius, string sps, string spe, int expectedNumberOfIntersections)
6669
{
6770
var circle = new Circle2D(Point2D.Parse(sc), radius);
6871
var line = new Line2D(Point2D.Parse(sps), Point2D.Parse(spe));
72+
6973
var actual = circle.IntersectWith(line);
70-
Assert.That(actual.Length, Is.EqualTo(2));
7174

72-
var expected = new[] { Point2D.Parse(esp0), Point2D.Parse(esp1) };
73-
AssertGeometry.AreEqual(actual[0], expected[0]);
74-
AssertGeometry.AreEqual(actual[1], expected[1]);
75+
Assert.That(actual.Count(), Is.EqualTo(expectedNumberOfIntersections));
7576
}
7677

7778
[TestCase("0,0", 1.41421356 /*=sqrt(2)*/, "0,0", "+1,+1", "+1,+1")]

0 commit comments

Comments
 (0)