mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 23:58:48 +00:00
[ci skip] Add unit tests for IsOnLine
This commit is contained in:
parent
3607034818
commit
d1959f4ba6
@ -1,6 +1,7 @@
|
||||
using System.Numerics;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using X10D.Core;
|
||||
using X10D.Drawing;
|
||||
using X10D.Numerics;
|
||||
|
||||
namespace X10D.Tests.Numerics;
|
||||
@ -18,6 +19,32 @@ public class Vector2Tests
|
||||
Assert.AreEqual(2, y);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOnLine_ShouldReturnTrue_ForPointOnLine()
|
||||
{
|
||||
Vector2 start = Vector2.Zero;
|
||||
Vector2 end = Vector2.UnitX;
|
||||
Vector2 point = new Vector2(0.5f, 0.0f);
|
||||
var line = new LineF(start, end);
|
||||
|
||||
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_ForPointNotOnLine()
|
||||
{
|
||||
Vector2 start = Vector2.Zero;
|
||||
Vector2 end = Vector2.UnitX;
|
||||
Vector2 point = new Vector2(0.5f, 1.0f);
|
||||
var line = new LineF(start, end);
|
||||
|
||||
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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user