Added Rectangle point and line tests
This commit is contained in:
parent
561446f541
commit
25522f06f6
@ -10,13 +10,23 @@ namespace AdventOfCode.Tests._2d_shapes
|
||||
[SetUp]
|
||||
public void SetupLine()
|
||||
{
|
||||
TestRectangle = new Rectangle(new Point(1,1), new Point(6,3));
|
||||
TestRectangle = new Rectangle(new Point(3,3), new Point(9,6));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PointDoesIntersectRectangle()
|
||||
public void PointDoesIntersectOnCornerOneRectangle()
|
||||
{
|
||||
Point testPoint = new Point(1,1);
|
||||
Point testPoint = new Point(3,3);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PointDoesIntersectOnCornerTwoRectangle()
|
||||
{
|
||||
Point testPoint = new Point(9, 6);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
@ -26,7 +36,7 @@ namespace AdventOfCode.Tests._2d_shapes
|
||||
[Test]
|
||||
public void PointDoesIntersectOnLineRectangle()
|
||||
{
|
||||
Point testPoint = new Point(3, 1);
|
||||
Point testPoint = new Point(3, 3);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
@ -36,11 +46,111 @@ namespace AdventOfCode.Tests._2d_shapes
|
||||
[Test]
|
||||
public void PointDoesIntersectInRectangle()
|
||||
{
|
||||
Point testPoint = new Point(3, 3);
|
||||
Point testPoint = new Point(5, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PointDoesNotIntersectInRectangle()
|
||||
{
|
||||
Point testPoint = new Point(1, 1);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineIntersectFrontRectangle()
|
||||
{
|
||||
Line testPoint = new Line(1, 4, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineIntersectBackRectangle()
|
||||
{
|
||||
Line testPoint = new Line(6, 4, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineIntersectInsideRectangle()
|
||||
{
|
||||
Line testPoint = new Line(1, 3, 3);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineIntersectFrontTopRectangle()
|
||||
{
|
||||
Line testPoint = new Line(1, 3, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LinetersectTopCornerEndRectangle()
|
||||
{
|
||||
Line testPoint = new Line(9, 6, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineIntersectBottomCornerRectangle()
|
||||
{
|
||||
Line testPoint = new Line(9, 6, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineNotIntersectTopRectangle()
|
||||
{
|
||||
Line testPoint = new Line(4, 1, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineNotIntersectBeforeEndAtStartRectangle()
|
||||
{
|
||||
Line testPoint = new Line(10, 5, 5);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LineNotIntersectStartFromEndRectangle()
|
||||
{
|
||||
Line testPoint = new Line(0, 5, 3);
|
||||
|
||||
bool intersects = TestRectangle.Intersect(testPoint);
|
||||
|
||||
Assert.That(intersects, Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user