AdventOfCode/AdventOfCode.Tests/2d-shapes/LineTests.cs
2023-12-10 14:42:35 +01:00

77 lines
1.7 KiB
C#

using AdventOfCode.Core.Shared.Grid;
namespace AdventOfCode.Tests._2d_shapes
{
[TestFixture]
public class LineTests
{
private Line TestLine;
[SetUp]
public void SetupLine()
{
TestLine = new Line(3, 1, 5);
}
[Test]
public void LineInfrontDoesNotIntersect()
{
Line line = new Line(0, 1, 3);
bool intersectResult = TestLine.Intersect(line);
Assert.That(intersectResult, Is.False);
}
[Test]
public void LineBehindDoesNotIntersect()
{
Line line = new Line(8, 1, 3);
bool intersectResult = TestLine.Intersect(line);
Assert.That(intersectResult, Is.False);
}
[Test]
public void LineInfrontDoesIntersect()
{
Line line = new Line(0, 1, 4);
bool intersectResult = TestLine.Intersect(line);
Assert.That(intersectResult, Is.True);
}
[Test]
public void LineBehindDoesIntersect()
{
Line line = new Line(7, 1, 3);
bool intersectResult = TestLine.Intersect(line);
Assert.That(intersectResult, Is.True);
}
[Test]
public void LineInLineDoesIntersect()
{
Line line = new Line(4, 1, 2);
bool intersectResult = TestLine.Intersect(line);
Assert.That(intersectResult, Is.True);
}
[Test]
public void LineOverLineDoesIntersect()
{
Line line = new Line(2, 1, 8);
bool intersectResult = TestLine.Intersect(line);
Assert.That(intersectResult, Is.True);
}
}
}