-
Notifications
You must be signed in to change notification settings - Fork 299
/
Copy pathLineIntersection_Tests.cs
61 lines (41 loc) · 2.41 KB
/
LineIntersection_Tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Advanced.Algorithms.Geometry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced.Algorithms.Tests.Geometry
{
[TestClass]
public class LineIntersectionTests
{
[TestMethod]
public void LineIntersection_Smoke_Test()
{
var pointComparer = new PointComparer();
var line1 = new Line(new Point(1, 1), new Point(10, 1));
var line2 = new Line(new Point(1, 2), new Point(10, 2));
Assert.IsTrue(pointComparer.Equals(null, LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(10, 0), new Point(0, 10));
line2 = new Line(new Point(0, 10), new Point(10, 10));
Assert.IsTrue(pointComparer.Equals(new Point(0, 10), LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(0, 0), new Point(10, 10));
line2 = new Line(new Point(0, 10), new Point(10, 10));
Assert.IsTrue(pointComparer.Equals(new Point(10, 10), LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(10, 0), new Point(0, 10));
line2 = new Line(new Point(0, 0), new Point(10, 10));
Assert.IsTrue(pointComparer.Equals(new Point(5, 5), LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(-5, -5), new Point(0, 0));
line2 = new Line(new Point(1, 1), new Point(10, 10));
Assert.IsTrue(pointComparer.Equals(default, LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(3, -5), new Point(3, 10));
line2 = new Line(new Point(0, 5), new Point(10, 5));
Assert.IsTrue(pointComparer.Equals(new Point(3, 5), LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(0, 5), new Point(10, 5));
line2 = new Line(new Point(3, -5), new Point(3, 10));
Assert.IsTrue(pointComparer.Equals(new Point(3, 5), LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(0, 5), new Point(10, 5));
line2 = new Line(new Point(3, -5), new Point(5, 15));
Assert.IsTrue(pointComparer.Equals(new Point(4, 5), LineIntersection.Find(line1, line2)));
line1 = new Line(new Point(0, -5), new Point(0, 5));
line2 = new Line(new Point(-3, 0), new Point(3, 0));
Assert.IsTrue(pointComparer.Equals(new Point(0, 0), LineIntersection.Find(line1, line2)));
}
}
}