mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-11 15:58:40 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
namespace TestSystem;
|
|
|
|
[TestClass]
|
|
public class TriangleTest
|
|
{
|
|
[TestMethod]
|
|
public void TestTrianglePerimeter()
|
|
{
|
|
Triangle triangle = new Triangle( new Vector3( 0, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 1, 0, 0 ) );
|
|
|
|
Assert.AreEqual( 3.4142137f, triangle.Perimeter );
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestTriangleArea()
|
|
{
|
|
Triangle triangle = new Triangle( new Vector3( 0, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 1, 0, 0 ) );
|
|
|
|
Assert.AreEqual( triangle.Area, 0.5f );
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestTriangleIsRight()
|
|
{
|
|
Triangle triangle = new Triangle( new Vector3( 0, 0, 0 ), new Vector3( 0, 3, 0 ), new Vector3( 4, 0, 0 ) );
|
|
|
|
Assert.IsTrue( triangle.IsRight );
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
public void TestClosestPointWithPointOutsideTriangle()
|
|
{
|
|
Triangle triangle = new Triangle( new Vector3( -1, 0, 0 ), new Vector3( 0, 2, 0 ), new Vector3( 1, 0, 0 ) );
|
|
Vector3 closestPoint = triangle.ClosestPoint( new Vector3( -1000, 0, 0 ) );
|
|
|
|
Assert.AreEqual( closestPoint, new Vector3( -1, 0, 0 ) );
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestClosestPointWithPointInsideTriangle()
|
|
{
|
|
Triangle triangle = new Triangle( new Vector3( -100, 0, 0 ), new Vector3( 0, 100, 0 ), new Vector3( 100, 0, 0 ) );
|
|
Vector3 closestPoint = triangle.ClosestPoint( new Vector3( 10, 15, 0 ) );
|
|
|
|
Assert.IsTrue( closestPoint == new Vector3( 10, 15, 0 ) );
|
|
}
|
|
|
|
}
|