1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:58:49 +00:00

test: add tests for Point.IsOnLine and PointF.IsOnLine

This commit is contained in:
Oliver Booth 2023-04-01 00:30:04 +01:00
parent 6e7e162ffe
commit 8b768f824c
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
2 changed files with 44 additions and 0 deletions

View File

@ -7,6 +7,28 @@ namespace X10D.Tests.Drawing;
[TestClass]
public class PointFTests
{
[TestMethod]
public void IsOnLine_ShouldReturnTrue_GivenPointOnLine()
{
var point = new PointF(1.0f, 0.0f);
var line = new LineF(PointF.Empty, new PointF(2.0f, 0.0f));
Assert.IsTrue(point.IsOnLine(line));
Assert.IsTrue(point.IsOnLine(line.Start, line.End));
Assert.IsTrue(point.IsOnLine(line.Start.ToVector2(), line.End.ToVector2()));
}
[TestMethod]
public void IsOnLine_ShouldReturnFalse_GivenPointNotOnLine()
{
var point = new PointF(1.0f, 1.0f);
var line = new LineF(PointF.Empty, new PointF(2.0f, 0.0f));
Assert.IsFalse(point.IsOnLine(line));
Assert.IsFalse(point.IsOnLine(line.Start, line.End));
Assert.IsFalse(point.IsOnLine(line.Start.ToVector2(), line.End.ToVector2()));
}
[TestMethod]
public void Round_ShouldRoundToNearestInteger_GivenNoParameters()
{

View File

@ -7,6 +7,28 @@ namespace X10D.Tests.Drawing;
[TestClass]
public class PointTests
{
[TestMethod]
public void IsOnLine_ShouldReturnTrue_GivenPointOnLine()
{
var point = new Point(1, 0);
var line = new Line(Point.Empty, new Point(2, 0));
Assert.IsTrue(point.IsOnLine(line));
Assert.IsTrue(point.IsOnLine(line.Start, line.End));
Assert.IsTrue(point.IsOnLine(line.Start.ToVector2(), line.End.ToVector2()));
}
[TestMethod]
public void IsOnLine_ShouldReturnFalse_GivenPointNotOnLine()
{
var point = new Point(1, 1);
var line = new Line(Point.Empty, new Point(2, 0));
Assert.IsFalse(point.IsOnLine(line));
Assert.IsFalse(point.IsOnLine(line.Start, line.End));
Assert.IsFalse(point.IsOnLine(line.Start.ToVector2(), line.End.ToVector2()));
}
[TestMethod]
public void ToSize_ShouldReturnSize_WithEquivalentMembers()
{