Remove Point2 (#875)

* Added `CalculateMinimumVector2` and `CalculateMaximumVector2` as replacement for `Point2.Minimum` and `Point2.Maximum`

* Remove `Point2`
This commit is contained in:
Christopher Whitley
2024-05-29 01:32:50 -04:00
committed by GitHub
parent 0427aa3ded
commit 9239fced04
35 changed files with 623 additions and 897 deletions
@@ -20,7 +20,7 @@ namespace MonoGame.Extended.Collisions.Tests
public CollisionComponentTests()
{
_collisionComponent = new CollisionComponent(new RectangleF(Point2.Zero, new Point2(10, 10)));
_collisionComponent = new CollisionComponent(new RectangleF(Vector2.Zero, new Vector2(10, 10)));
}
#region Circle Circle
@@ -28,8 +28,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorSameCircleTest()
{
Point2 pos1 = Point2.Zero;
Point2 pos2 = Point2.Zero;
Vector2 pos1 = Vector2.Zero;
Vector2 pos2 = Vector2.Zero;
IShapeF shape1 = new CircleF(pos1, 2.0f);
IShapeF shape2 = new CircleF(pos2, 2.0f);
@@ -55,8 +55,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorSlightlyOverlappingCircleTest()
{
Point2 pos1 = new Point2(0, 1.5f);
Point2 pos2 = Point2.Zero;
Vector2 pos1 = new Vector2(0, 1.5f);
Vector2 pos2 = Vector2.Zero;
IShapeF shape1 = new CircleF(pos1, 2.0f);
IShapeF shape2 = new CircleF(pos2, 2.0f);
@@ -85,8 +85,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorSlightlyOverlappingOffAxisTest()
{
Point2 pos1 = new Point2(2, 2.5f);
Point2 pos2 = new Point2(2, 1);
Vector2 pos1 = new Vector2(2, 2.5f);
Vector2 pos2 = new Vector2(2, 1);
IShapeF shape1 = new CircleF(pos1, 2.0f);
IShapeF shape2 = new CircleF(pos2, 2.0f);
@@ -116,8 +116,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationZeroRadiusCircleCircleTest()
{
Point2 pos1 = new Point2(0, 1.5f);
Point2 pos2 = Point2.Zero;
Vector2 pos1 = new Vector2(0, 1.5f);
Vector2 pos2 = Vector2.Zero;
IShapeF shape1 = new CircleF(pos1, 0);
IShapeF shape2 = new CircleF(pos2, 2.0f);
@@ -150,8 +150,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorCircleRectangleTest()
{
Point2 pos1 = new Point2(0, 1);
Point2 pos2 = new Point2(-2, -1);
Vector2 pos1 = new Vector2(0, 1);
Vector2 pos2 = new Vector2(-2, -1);
IShapeF shape1 = new CircleF(pos1, 2.0f);
IShapeF shape2 = new RectangleF(pos2, new SizeF(4, 2));
@@ -179,8 +179,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorCircleContainedInRectangleTest()
{
Point2 pos1 = new Point2(0, 0);
Point2 pos2 = new Point2(-2, -1);
Vector2 pos1 = new Vector2(0, 0);
Vector2 pos2 = new Vector2(-2, -1);
IShapeF shape1 = new CircleF(pos1, 1.0f);
IShapeF shape2 = new RectangleF(pos2, new SizeF(4, 2));
@@ -208,8 +208,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorCircleOffAxisRectangleTest()
{
Point2 pos1 = new Point2(2, 1);
Point2 pos2 = new Point2(-2, -1);
Vector2 pos1 = new Vector2(2, 1);
Vector2 pos2 = new Vector2(-2, -1);
IShapeF shape1 = new CircleF(pos1, 2.0f);
IShapeF shape2 = new RectangleF(pos2, new SizeF(4, 2));
@@ -241,8 +241,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorRectangleRectangleTest()
{
Point2 pos1 = new Point2(0, 0);
Point2 pos2 = new Point2(-2, -1);
Vector2 pos1 = new Vector2(0, 0);
Vector2 pos2 = new Vector2(-2, -1);
IShapeF shape1 = new RectangleF(pos1, new SizeF(4, 2));
IShapeF shape2 = new RectangleF(pos2, new SizeF(4, 2));
@@ -270,8 +270,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void PenetrationVectorRectangleRectangleOffAxisTest()
{
Point2 pos1 = new Point2(4, 2);
Point2 pos2 = new Point2(3, 1);
Vector2 pos1 = new Vector2(4, 2);
Vector2 pos2 = new Vector2(3, 1);
IShapeF shape1 = new RectangleF(pos1, new SizeF(4, 2));
IShapeF shape2 = new RectangleF(pos2, new SizeF(4, 2));
@@ -303,8 +303,8 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void Actors_is_colliding()
{
var staticBounds = new RectangleF(new Point2(0, 0), new SizeF(1, 1));
var anotherStaticBounds = new RectangleF(new Point2(0, 0), new SizeF(1, 1));
var staticBounds = new RectangleF(new Vector2(0, 0), new SizeF(1, 1));
var anotherStaticBounds = new RectangleF(new Vector2(0, 0), new SizeF(1, 1));
var staticActor = new CollisionIndicatingActor(staticBounds);
var anotherStaticActor = new CollisionIndicatingActor(anotherStaticBounds);
_collisionComponent.Insert(staticActor);
@@ -319,13 +319,13 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void Actors_is_not_colliding_when_dynamic_actor_is_moved_out_of_collision_bounds()
{
var staticBounds = new RectangleF(new Point2(0, 0), new SizeF(1, 1));
var dynamicBounds = new RectangleF(new Point2(0, 0), new SizeF(1, 1));
var staticBounds = new RectangleF(new Vector2(0, 0), new SizeF(1, 1));
var dynamicBounds = new RectangleF(new Vector2(0, 0), new SizeF(1, 1));
var staticActor = new CollisionIndicatingActor(staticBounds);
var dynamicActor = new CollisionIndicatingActor(dynamicBounds);
_collisionComponent.Insert(staticActor);
_collisionComponent.Insert(dynamicActor);
dynamicActor.MoveTo(new Point2(2, 2));
dynamicActor.MoveTo(new Vector2(2, 2));
_collisionComponent.Update(_gameTime);
@@ -336,17 +336,17 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void Actors_is_colliding_when_dynamic_actor_is_moved_after_update()
{
var staticBounds = new RectangleF(new Point2(0, 0), new SizeF(1, 1));
var staticBounds = new RectangleF(new Vector2(0, 0), new SizeF(1, 1));
var staticActor = new CollisionIndicatingActor(staticBounds);
_collisionComponent.Insert(staticActor);
for (int i = 0; i < QuadTree.QuadTree.DefaultMaxObjectsPerNode; i++)
{
var fillerBounds = new RectangleF(new Point2(0, 2), new SizeF(.1f, .1f));
var fillerBounds = new RectangleF(new Vector2(0, 2), new SizeF(.1f, .1f));
var fillerActor = new CollisionIndicatingActor(fillerBounds);
_collisionComponent.Insert(fillerActor);
}
var dynamicBounds = new RectangleF(new Point2(2, 2), new SizeF(1, 1));
var dynamicBounds = new RectangleF(new Vector2(2, 2), new SizeF(1, 1));
var dynamicActor = new CollisionIndicatingActor(dynamicBounds);
_collisionComponent.Insert(dynamicActor);
@@ -354,7 +354,7 @@ namespace MonoGame.Extended.Collisions.Tests
Assert.False(staticActor.IsColliding);
Assert.False(dynamicActor.IsColliding);
dynamicActor.MoveTo(new Point2(0, 0));
dynamicActor.MoveTo(new Vector2(0, 0));
_collisionComponent.Update(_gameTime);
Assert.True(dynamicActor.IsColliding);
@@ -364,13 +364,13 @@ namespace MonoGame.Extended.Collisions.Tests
[Fact]
public void Actors_is_colliding_when_dynamic_actor_is_moved_into_collision_bounds()
{
var staticBounds = new RectangleF(new Point2(0, 0), new SizeF(1, 1));
var dynamicBounds = new RectangleF(new Point2(2, 2), new SizeF(1, 1));
var staticBounds = new RectangleF(new Vector2(0, 0), new SizeF(1, 1));
var dynamicBounds = new RectangleF(new Vector2(2, 2), new SizeF(1, 1));
var staticActor = new CollisionIndicatingActor(staticBounds);
var dynamicActor = new CollisionIndicatingActor(dynamicBounds);
_collisionComponent.Insert(staticActor);
_collisionComponent.Insert(dynamicActor);
dynamicActor.MoveTo(new Point2(0, 0));
dynamicActor.MoveTo(new Vector2(0, 0));
_collisionComponent.Update(_gameTime);
@@ -406,7 +406,7 @@ namespace MonoGame.Extended.Collisions.Tests
public bool IsColliding { get; private set; }
public void MoveTo(Point2 position)
public void MoveTo(Vector2 position)
{
_bounds = new RectangleF(position, _bounds.Size);
}
@@ -1,10 +1,11 @@
using System;
using Microsoft.Xna.Framework;
namespace MonoGame.Extended.Tests
{
public static class AssertExtensions
{
public static bool AreApproximatelyEqual(Point2 firstPoint, Point2 secondPoint)
public static bool AreApproximatelyEqual(Vector2 firstPoint, Vector2 secondPoint)
{
return Math.Abs(firstPoint.X - secondPoint.X) < float.Epsilon &&
Math.Abs(firstPoint.Y - secondPoint.Y) < float.Epsilon;
@@ -18,4 +19,4 @@ namespace MonoGame.Extended.Tests
Math.Abs(firstRectangle.Height - secondRectangle.Height) < float.Epsilon;
}
}
}
}
@@ -0,0 +1,55 @@
using Microsoft.Xna.Framework;
namespace MonoGame.Extended.Tests;
public class MathExtendedTests
{
[Fact]
public void CalculateMinimumVector2_Returns_Expected()
{
Vector2 a = new Vector2(1, 4);
Vector2 b = new Vector2(3, 2);
Vector2 expected = new Vector2(1, 2);
Vector2 actual = MathExtended.CalculateMinimumVector2(a, b);
Assert.Equal(expected, actual);
}
[Fact]
public void CalculateMinimumVector2_Out_Expected()
{
Vector2 a = new Vector2(1, 4);
Vector2 b = new Vector2(3, 2);
Vector2 expected = new Vector2(1, 2);
MathExtended.CalculateMinimumVector2(a, b, out Vector2 actual);
Assert.Equal(expected, actual);
}
[Fact]
public void CalculateMaximumVector2_Returns_Expected()
{
Vector2 a = new Vector2(1, 4);
Vector2 b = new Vector2(3, 2);
Vector2 expected = new Vector2(3, 4);
Vector2 actual = MathExtended.CalculateMaximumVector2(a, b);
Assert.Equal(expected, actual);
}
[Fact]
public void CalculateMaximumVector2_Out_Expected()
{
Vector2 a = new Vector2(1, 4);
Vector2 b = new Vector2(3, 2);
Vector2 expected = new Vector2(3, 4);
MathExtended.CalculateMaximumVector2(a, b, out Vector2 actual);
Assert.Equal(expected, actual);
}
}
@@ -13,17 +13,17 @@
// get
// {
// yield return
// new TestCaseData(new Point2(), new Vector2()).SetName(
// new TestCaseData(new Vector2(), new Vector2()).SetName(
// "The empty bounding rectangle has the expected position and radii.");
// yield return
// new TestCaseData(new Point2(5, 5), new Vector2(15, 15)).SetName(
// new TestCaseData(new Vector2(5, 5), new Vector2(15, 15)).SetName(
// "A non-empty bounding rectangle has the expected position and radii.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(ConstructorTestCases))]
// public void Constructor(Point2 centre, Vector2 radii)
// public void Constructor(Vector2 centre, Vector2 radii)
// {
// var boundingRectangle = new BoundingRectangle(centre, radii);
// Assert.Equal(centre, boundingRectangle.Center);
@@ -35,12 +35,12 @@
// get
// {
// yield return
// new TestCaseData(new Point2(), new Point2(), new BoundingRectangle()).SetName(
// new TestCaseData(new Vector2(), new Vector2(), new BoundingRectangle()).SetName(
// "The bounding rectangle created from the zero minimum point and zero maximum point is the empty bounding rectangle.")
// ;
// yield return
// new TestCaseData(new Point2(5, 5), new Point2(15, 15),
// new BoundingRectangle(new Point2(10, 10), new Size2(5, 5))).SetName(
// new TestCaseData(new Vector2(5, 5), new Vector2(15, 15),
// new BoundingRectangle(new Vector2(10, 10), new Size2(5, 5))).SetName(
// "The bounding rectangle created from the non-zero minimum point and the non-zero maximum point is the expected bounding rectangle.")
// ;
// }
@@ -48,7 +48,7 @@
// [Fact]
// [TestCaseSource(nameof(CreateFromMinimumMaximumTestCases))]
// public void CreateFromMinimumMaximum(Point2 minimum, Point2 maximum, BoundingRectangle expectedBoundingRectangle)
// public void CreateFromMinimumMaximum(Vector2 minimum, Vector2 maximum, BoundingRectangle expectedBoundingRectangle)
// {
// var actualBoundingRectangle = BoundingRectangle.CreateFrom(minimum, maximum);
// Assert.Equal(expectedBoundingRectangle, actualBoundingRectangle);
@@ -62,22 +62,22 @@
// new TestCaseData(null, new BoundingRectangle()).SetName(
// "The bounding rectangle created from null points is the empty bounding rectangle.");
// yield return
// new TestCaseData(new Point2[0], new BoundingRectangle()).SetName(
// new TestCaseData(new Vector2[0], new BoundingRectangle()).SetName(
// "The bounding rectangle created from the empty set of points is the empty bounding rectangle.");
// yield return
// new TestCaseData(
// new[]
// {
// new Point2(5, 5), new Point2(10, 10), new Point2(15, 15), new Point2(-5, -5),
// new Point2(-15, -15)
// }, new BoundingRectangle(new Point2(0, 0), new Size2(15, 15))).SetName(
// new Vector2(5, 5), new Vector2(10, 10), new Vector2(15, 15), new Vector2(-5, -5),
// new Vector2(-15, -15)
// }, new BoundingRectangle(new Vector2(0, 0), new Size2(15, 15))).SetName(
// "The bounding rectangle created from a non-empty set of points is the expected bounding rectangle.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(CreateFromPointsTestCases))]
// public void CreateFromPoints(Point2[] points, BoundingRectangle expectedBoundingRectangle)
// public void CreateFromPoints(Vector2[] points, BoundingRectangle expectedBoundingRectangle)
// {
// var actualBoundingRectangle = BoundingRectangle.CreateFrom(points);
// Assert.Equal(expectedBoundingRectangle, actualBoundingRectangle);
@@ -92,7 +92,7 @@
// "The bounding rectangle created from the empty bounding rectangle transformed by the identity matrix is the empty bounding rectangle.")
// ;
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Size2(20, 20)), Matrix3x2.CreateScale(2), new BoundingRectangle(new Point2(0, 0), new Size2(40, 40))).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Size2(20, 20)), Matrix3x2.CreateScale(2), new BoundingRectangle(new Vector2(0, 0), new Size2(40, 40))).SetName(
// "The bounding rectangle created from a non-empty bounding rectangle transformed by a non-identity matrix is the expected bounding rectangle.")
// ;
// }
@@ -115,8 +115,8 @@
// new TestCaseData(new BoundingRectangle(), new BoundingRectangle(), new BoundingRectangle()).SetName(
// "The union of two empty bounding rectangles is the empty bounding rectangle.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Size2(15, 15)),
// new BoundingRectangle(new Point2(20, 20), new Size2(40, 40)), new BoundingRectangle(new Point2(20, 20), new Size2(40, 40)))
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Size2(15, 15)),
// new BoundingRectangle(new Vector2(20, 20), new Size2(40, 40)), new BoundingRectangle(new Vector2(20, 20), new Size2(40, 40)))
// .SetName(
// "The union of two non-empty bounding rectangles is the expected bounding rectangle.");
// }
@@ -138,13 +138,13 @@
// new TestCaseData(new BoundingRectangle(), new BoundingRectangle(), new BoundingRectangle()).SetName(
// "The intersection of two empty bounding rectangles is the empty bounding box.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(-10, -10), new Size2(15, 15)),
// new BoundingRectangle(new Point2(20, 20), new Size2(40, 40)),
// new BoundingRectangle(new Point2(-7.5f, -7.5f), new Size2(12.5f, 12.5f))).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(-10, -10), new Size2(15, 15)),
// new BoundingRectangle(new Vector2(20, 20), new Size2(40, 40)),
// new BoundingRectangle(new Vector2(-7.5f, -7.5f), new Size2(12.5f, 12.5f))).SetName(
// "The intersection of two overlapping non-empty bounding rectangles is the expected bounding rectangle.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(-30, -30), new Size2(15, 15)),
// new BoundingRectangle(new Point2(20, 20), new Size2(10, 10)),
// new TestCaseData(new BoundingRectangle(new Vector2(-30, -30), new Size2(15, 15)),
// new BoundingRectangle(new Vector2(20, 20), new Size2(10, 10)),
// BoundingRectangle.Empty).SetName(
// "The intersection of two non-overlapping non-empty bounding rectangles is the empty bounding rectangle.");
// }
@@ -167,12 +167,12 @@
// new TestCaseData(new BoundingRectangle(), new BoundingRectangle(), true).SetName(
// "Two empty bounding rectangles intersect.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(-10, -10), new Size2(15, 15)),
// new BoundingRectangle(new Point2(20, 20), new Size2(40, 40)), true).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(-10, -10), new Size2(15, 15)),
// new BoundingRectangle(new Vector2(20, 20), new Size2(40, 40)), true).SetName(
// "Two overlapping non-empty bounding rectangles intersect.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(-40, -50), new Size2(15, 15)),
// new BoundingRectangle(new Point2(20, 20), new Size2(15, 15)), false).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(-40, -50), new Size2(15, 15)),
// new BoundingRectangle(new Vector2(20, 20), new Size2(15, 15)), false).SetName(
// "Two non-overlapping non-empty bounding rectangles do not intersect.");
// }
// }
@@ -190,14 +190,14 @@
// get
// {
// yield return
// new TestCaseData(new BoundingRectangle(), new Point2(), true).SetName(
// new TestCaseData(new BoundingRectangle(), new Vector2(), true).SetName(
// "The empty bounding rectangle contains the zero point.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Size2(15, 15)), new Point2(-15, -15), true)
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Size2(15, 15)), new Vector2(-15, -15), true)
// .SetName(
// "A non-empty bounding rectangle contains a point inside it.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Size2(15, 15)), new Point2(-16, 15), false)
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Size2(15, 15)), new Vector2(-16, 15), false)
// .SetName(
// "A non-empty bounding rectangle does not contain a point outside it.");
// }
@@ -205,7 +205,7 @@
// [Fact]
// [TestCaseSource(nameof(ContainsPointTestCases))]
// public void ContainsPoint(BoundingRectangle boundingRectangle, Point2 point, bool expectedToContainPoint)
// public void ContainsPoint(BoundingRectangle boundingRectangle, Vector2 point, bool expectedToContainPoint)
// {
// Assert.Equal(expectedToContainPoint, boundingRectangle.Contains(point));
// Assert.Equal(expectedToContainPoint, BoundingRectangle.Contains(boundingRectangle, point));
@@ -216,16 +216,16 @@
// get
// {
// yield return
// new TestCaseData(new BoundingRectangle(), new Point2(), new Point2()).SetName(
// new TestCaseData(new BoundingRectangle(), new Vector2(), new Vector2()).SetName(
// "The closest point on the empty bounding rectangle to the zero point is the zero point.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Point2(50, 50)), new Point2(25, 25),
// new Point2(25, 25)).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Vector2(50, 50)), new Vector2(25, 25),
// new Vector2(25, 25)).SetName(
// "The closest point on a non-empty bounding rectangle to a point which is inside the bounding rectangle is that point.")
// ;
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Point2(50, 50)), new Point2(400, 0),
// new Point2(50, 0)).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Vector2(50, 50)), new Vector2(400, 0),
// new Vector2(50, 0)).SetName(
// "The closest point on a non-empty bounding rectangle to a point which is outside the bounding rectangle is the expected point.")
// ;
// }
@@ -233,7 +233,7 @@
// [Fact]
// [TestCaseSource(nameof(ClosestPointTestCases))]
// public void ClosestPoint(BoundingRectangle boundingRectangle, Point2 point, Point2 expectedClosestPoint)
// public void ClosestPoint(BoundingRectangle boundingRectangle, Vector2 point, Vector2 expectedClosestPoint)
// {
// var actualClosestPoint = boundingRectangle.ClosestPointTo(point);
// Assert.Equal(expectedClosestPoint, actualClosestPoint);
@@ -249,14 +249,14 @@
// ;
// yield return
// new TestCaseData(
// new BoundingRectangle(new Point2(0, 0), new Size2(float.MaxValue, float.MinValue)),
// new BoundingRectangle(new Point2(0, 0),
// new Point2(float.MinValue, float.MaxValue)), false).SetName(
// new BoundingRectangle(new Vector2(0, 0), new Size2(float.MaxValue, float.MinValue)),
// new BoundingRectangle(new Vector2(0, 0),
// new Vector2(float.MinValue, float.MaxValue)), false).SetName(
// "Two different non-empty bounding rectangles are not equal.");
// yield return
// new TestCaseData(
// new BoundingRectangle(new Point2(0, 0), new Size2(float.MinValue, float.MaxValue)),
// new BoundingRectangle(new Point2(0, 0),
// new BoundingRectangle(new Vector2(0, 0), new Size2(float.MinValue, float.MaxValue)),
// new BoundingRectangle(new Vector2(0, 0),
// new Size2(float.MinValue, float.MaxValue)), true).SetName(
// "Two identical non-empty bounding rectangles are equal.");
// }
@@ -303,12 +303,12 @@
// new TestCaseData(new BoundingRectangle(), new BoundingRectangle(), true).SetName(
// "Two empty bounding rectangles have the same hash code.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Size2(50, 50)),
// new BoundingRectangle(new Point2(0, 0), new Size2(50, 50)), true).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Size2(50, 50)),
// new BoundingRectangle(new Vector2(0, 0), new Size2(50, 50)), true).SetName(
// "Two indentical non-empty bounding rectangles have the same hash code.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(0, 0), new Size2(50, 50)),
// new BoundingRectangle(new Point2(50, 50), new Size2(50, 50)), false).SetName(
// new TestCaseData(new BoundingRectangle(new Vector2(0, 0), new Size2(50, 50)),
// new BoundingRectangle(new Vector2(50, 50), new Size2(50, 50)), false).SetName(
// "Two different non-empty bounding rectangles do not have the same hash code.");
// }
// }
@@ -333,7 +333,7 @@
// new TestCaseData(new BoundingRectangle(), new Rectangle()).SetName(
// "The empty bounding rectangle point converted to a rectangle is the empty rectangle.");
// yield return
// new TestCaseData(new BoundingRectangle(new Point2(25, 25), new Size2(25, 25)),
// new TestCaseData(new BoundingRectangle(new Vector2(25, 25), new Size2(25, 25)),
// new Rectangle(0, 0, 50, 50)).SetName(
// "A non-empty bounding rectangle converted to a rectangle is the expected rectangle.");
// }
@@ -356,7 +356,7 @@
// "The empty rectangle converted to a bounding rectangle is the empty bounding rectangle.");
// yield return
// new TestCaseData(new Rectangle(0, 0, 50, 50),
// new BoundingRectangle(new Point2(25, 25), new Size2(25, 25))).SetName(
// new BoundingRectangle(new Vector2(25, 25), new Size2(25, 25))).SetName(
// "A non-empty rectangle converted to a bounding rectangle is the expected bounding rectangle.");
// }
// }
@@ -375,11 +375,11 @@
// {
// yield return
// new TestCaseData(new BoundingRectangle(),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radii: {1}", new Point2(),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radii: {1}", new Vector2(),
// new Vector2())).SetName(
// "The empty bounding rectangle has the expected string representation using the current culture.");
// yield return new TestCaseData(new BoundingRectangle(new Point2(5.1f, -5.123f), new Size2(5.4f, -5.4123f)),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radii: {1}", new Point2(5.1f, -5.123f),
// yield return new TestCaseData(new BoundingRectangle(new Vector2(5.1f, -5.123f), new Size2(5.4f, -5.4123f)),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radii: {1}", new Vector2(5.1f, -5.123f),
// new Vector2(5.4f, -5.4123f))).SetName(
// "A non-empty bounding rectangle has the expected string representation using the current culture.");
// }
@@ -13,8 +13,8 @@ public class CircleFTests
[Fact]
public void CircCircIntersectionDiagonalCircleTest()
{
var circle = new CircleF(new Point2(16.0f, 16.0f), 16.0f);
var point = new Point2(0, 0);
var circle = new CircleF(new Vector2(16.0f, 16.0f), 16.0f);
var point = new Vector2(0, 0);
Assert.False(circle.Contains(point));
}
@@ -23,17 +23,17 @@ public class CircleFTests
// get
// {
// yield return
// new TestCaseData(new Point2(), 0.0f).SetName(
// new TestCaseData(new Vector2(), 0.0f).SetName(
// "The empty circle has the expected position and radius.");
// yield return
// new TestCaseData(new Point2(5, 5), 15f).SetName(
// new TestCaseData(new Vector2(5, 5), 15f).SetName(
// "A non-empty circle has the expected position and radius.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(ConstructorTestCases))]
// public void Constructor(Point2 centre, float radius)
// public void Constructor(Vector2 centre, float radius)
// {
// var circle = new CircleF(centre, radius);
// Assert.Equal(centre, circle.Center);
@@ -45,12 +45,12 @@ public class CircleFTests
// get
// {
// yield return
// new TestCaseData(new Point2(), new Point2(), new CircleF()).SetName(
// new TestCaseData(new Vector2(), new Vector2(), new CircleF()).SetName(
// "The bounding circle created from the zero minimum point and zero maximum point is the empty bounding circle.")
// ;
// yield return
// new TestCaseData(new Point2(5, 5), new Point2(15, 15),
// new CircleF(new Point2(10, 10), 5f)).SetName(
// new TestCaseData(new Vector2(5, 5), new Vector2(15, 15),
// new CircleF(new Vector2(10, 10), 5f)).SetName(
// "The bounding circle created from the non-zero minimum point and the non-zero maximum point is the expected bounding circle.")
// ;
// }
@@ -58,7 +58,7 @@ public class CircleFTests
// [Fact]
// [TestCaseSource(nameof(CreateFromMinimumMaximumTestCases))]
// public void CreateFromMinimumMaximum(Point2 minimum, Point2 maximum, CircleF expectedBoundingCircle)
// public void CreateFromMinimumMaximum(Vector2 minimum, Vector2 maximum, CircleF expectedBoundingCircle)
// {
// var actualBoundingCircle = CircleF.CreateFrom(minimum, maximum);
// Assert.Equal(expectedBoundingCircle, actualBoundingCircle);
@@ -72,22 +72,22 @@ public class CircleFTests
// new TestCaseData(null, new CircleF()).SetName(
// "The bounding circle created from null points is the empty bounding circle.");
// yield return
// new TestCaseData(new Point2[0], new CircleF()).SetName(
// new TestCaseData(new Vector2[0], new CircleF()).SetName(
// "The bounding circle created from the empty set of points is the empty bounding circle.");
// yield return
// new TestCaseData(
// new[]
// {
// new Point2(5, 5), new Point2(10, 10), new Point2(15, 15), new Point2(-5, -5),
// new Point2(-15, -15)
// }, new CircleF(new Point2(0, 0), 15)).SetName(
// new Vector2(5, 5), new Vector2(10, 10), new Vector2(15, 15), new Vector2(-5, -5),
// new Vector2(-15, -15)
// }, new CircleF(new Vector2(0, 0), 15)).SetName(
// "The bounding circle created from a non-empty set of points is the expected bounding circle.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(CreateFromPointsTestCases))]
// public void CreateFromPoints(Point2[] points, CircleF expectedCircle)
// public void CreateFromPoints(Vector2[] points, CircleF expectedCircle)
// {
// var actualCircle = CircleF.CreateFrom(points);
// Assert.Equal(expectedCircle, actualCircle);
@@ -101,12 +101,12 @@ public class CircleFTests
// new TestCaseData(new CircleF(), new CircleF(), true).SetName(
// "Two empty circles intersect.");
// yield return
// new TestCaseData(new CircleF(new Point2(-10, -10), 15),
// new CircleF(new Point2(20, 20), 40), true).SetName(
// new TestCaseData(new CircleF(new Vector2(-10, -10), 15),
// new CircleF(new Vector2(20, 20), 40), true).SetName(
// "Two overlapping non-empty circles intersect.");
// yield return
// new TestCaseData(new CircleF(new Point2(-40, -50), 15),
// new CircleF(new Point2(20, 20), 15), false).SetName(
// new TestCaseData(new CircleF(new Vector2(-40, -50), 15),
// new CircleF(new Vector2(20, 20), 15), false).SetName(
// "Two non-overlapping non-empty circles do not intersect.");
// }
// }
@@ -127,12 +127,12 @@ public class CircleFTests
// new TestCaseData(new CircleF(), new RectangleF(), true).SetName(
// "The empty circle and the empty rectangle intersect.");
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 15),
// new RectangleF(new Point2(0, 0), new Size2(40, 40)), true).SetName(
// new TestCaseData(new CircleF(new Vector2(0, 0), 15),
// new RectangleF(new Vector2(0, 0), new Size2(40, 40)), true).SetName(
// "The non-empty circle and a non-empty overlapping rectangle intersect.");
// yield return
// new TestCaseData(new CircleF(new Point2(-40, -50), 15),
// new RectangleF(new Point2(20, 20), new Size2(15, 15)), false).SetName(
// new TestCaseData(new CircleF(new Vector2(-40, -50), 15),
// new RectangleF(new Vector2(20, 20), new Size2(15, 15)), false).SetName(
// "The non-empty circle and a non-empty non-overlapping rectangle do not intersect.");
// }
// }
@@ -150,14 +150,14 @@ public class CircleFTests
// get
// {
// yield return
// new TestCaseData(new CircleF(), new Point2(), true).SetName(
// new TestCaseData(new CircleF(), new Vector2(), true).SetName(
// "The empty circle contains the zero point.");
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 15), new Point2(-15, -15), true)
// new TestCaseData(new CircleF(new Vector2(0, 0), 15), new Vector2(-15, -15), true)
// .SetName(
// "A non-empty circle contains a point inside it.");
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 15), new Point2(-16, 15), false)
// new TestCaseData(new CircleF(new Vector2(0, 0), 15), new Vector2(-16, 15), false)
// .SetName(
// "A non-empty circle does not contain a point outside it.");
// }
@@ -165,7 +165,7 @@ public class CircleFTests
// [Fact]
// [TestCaseSource(nameof(ContainsPointTestCases))]
// public void ContainsPoint(CircleF circle, Point2 point, bool expectedToContainPoint)
// public void ContainsPoint(CircleF circle, Vector2 point, bool expectedToContainPoint)
// {
// Assert.Equal(expectedToContainPoint, circle.Contains(point));
// Assert.Equal(expectedToContainPoint, CircleF.Contains(circle, point));
@@ -176,16 +176,16 @@ public class CircleFTests
// get
// {
// yield return
// new TestCaseData(new CircleF(), new Point2(), new Point2()).SetName(
// new TestCaseData(new CircleF(), new Vector2(), new Vector2()).SetName(
// "The closest point on the empty circle to the zero point is the zero point.");
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 50), new Point2(25, 25),
// new Point2(25, 25)).SetName(
// new TestCaseData(new CircleF(new Vector2(0, 0), 50), new Vector2(25, 25),
// new Vector2(25, 25)).SetName(
// "The closest point on a non-empty circle to a point which is inside the circle is that point.")
// ;
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 50), new Point2(400, 0),
// new Point2(50, 0)).SetName(
// new TestCaseData(new CircleF(new Vector2(0, 0), 50), new Vector2(400, 0),
// new Vector2(50, 0)).SetName(
// "The closest point on a non-empty circle to a point which is outside the circle is the expected point.")
// ;
// }
@@ -193,7 +193,7 @@ public class CircleFTests
// [Fact]
// [TestCaseSource(nameof(ClosestPointTestCases))]
// public void ClosestPoint(CircleF circle, Point2 point, Point2 expectedClosestPoint)
// public void ClosestPoint(CircleF circle, Vector2 point, Vector2 expectedClosestPoint)
// {
// var actualClosestPoint = circle.ClosestPointTo(point);
// Assert.Equal(expectedClosestPoint, actualClosestPoint);
@@ -204,18 +204,18 @@ public class CircleFTests
// get
// {
// yield return
// new TestCaseData(new CircleF(), 0.0f, new Point2()).SetName(
// new TestCaseData(new CircleF(), 0.0f, new Vector2()).SetName(
// "The boundary point on the empty circle at an angle is the zero point.");
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 50), MathHelper.PiOver2,
// new Point2(0, 50)).SetName(
// new TestCaseData(new CircleF(new Vector2(0, 0), 50), MathHelper.PiOver2,
// new Vector2(0, 50)).SetName(
// "The boundary point on a non-empty circle at an angle is the expected point.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(BoundaryPointTestCases))]
// public void BoundaryPointAt(CircleF circle, float angle, Point2 expectedPoint)
// public void BoundaryPointAt(CircleF circle, float angle, Vector2 expectedPoint)
// {
// var actualPoint = circle.BoundaryPointAt(angle);
// AssertExtensions.AreApproximatelyEqual(expectedPoint, actualPoint);
@@ -231,13 +231,13 @@ public class CircleFTests
// ;
// yield return
// new TestCaseData(
// new CircleF(new Point2(0, 0), float.MaxValue),
// new CircleF(new Point2(0, 0), float.MinValue), false).SetName(
// new CircleF(new Vector2(0, 0), float.MaxValue),
// new CircleF(new Vector2(0, 0), float.MinValue), false).SetName(
// "Two different non-empty circles are not equal.");
// yield return
// new TestCaseData(
// new CircleF(new Point2(0, 0), float.MinValue),
// new CircleF(new Point2(0, 0), float.MinValue), true).SetName(
// new CircleF(new Vector2(0, 0), float.MinValue),
// new CircleF(new Vector2(0, 0), float.MinValue), true).SetName(
// "Two identical non-empty circles are equal.");
// }
// }
@@ -283,12 +283,12 @@ public class CircleFTests
// new TestCaseData(new CircleF(), new CircleF(), true).SetName(
// "Two empty circles have the same hash code.");
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 50),
// new CircleF(new Point2(0, 0), 50), true).SetName(
// new TestCaseData(new CircleF(new Vector2(0, 0), 50),
// new CircleF(new Vector2(0, 0), 50), true).SetName(
// "Two indentical non-empty circles have the same hash code.");
// yield return
// new TestCaseData(new CircleF(new Point2(0, 0), 50),
// new CircleF(new Point2(50, 50), 50), false).SetName(
// new TestCaseData(new CircleF(new Vector2(0, 0), 50),
// new CircleF(new Vector2(50, 50), 50), false).SetName(
// "Two different non-empty circles do not have the same hash code.");
// }
// }
@@ -313,7 +313,7 @@ public class CircleFTests
// new TestCaseData(new CircleF(), new Rectangle()).SetName(
// "The empty circle converted to a rectangle is the empty integer rectangle.");
// yield return
// new TestCaseData(new CircleF(new Point2(25, 25), 25),
// new TestCaseData(new CircleF(new Vector2(25, 25), 25),
// new Rectangle(0, 0, 50, 50)).SetName(
// "A non-empty circle converted to a rectangle is the expected integer rectangle.");
// }
@@ -335,7 +335,7 @@ public class CircleFTests
// new TestCaseData(new CircleF(), new RectangleF()).SetName(
// "The empty circle converted to a rectangle is the empty float rectangle.");
// yield return
// new TestCaseData(new CircleF(new Point2(25, 25), 25),
// new TestCaseData(new CircleF(new Vector2(25, 25), 25),
// new RectangleF(0, 0, 50, 50)).SetName(
// "A non-empty circle converted to a rectangle is the expected float rectangle.");
// }
@@ -358,7 +358,7 @@ public class CircleFTests
// "The empty rectangle converted to a circle is the empty circle.");
// yield return
// new TestCaseData(new Rectangle(0, 0, 50, 50),
// new CircleF(new Point2(25, 25), 25)).SetName(
// new CircleF(new Vector2(25, 25), 25)).SetName(
// "A non-empty rectangle converted to a circle is the expected circle.");
// }
// }
@@ -380,7 +380,7 @@ public class CircleFTests
// "The empty rectangle converted to a circle is the empty circle.");
// yield return
// new TestCaseData(new RectangleF(0, 0, 50, 50),
// new CircleF(new Point2(25, 25), 25)).SetName(
// new CircleF(new Vector2(25, 25), 25)).SetName(
// "A non-empty rectangle converted to a circle is the expected circle.");
// }
// }
@@ -399,11 +399,11 @@ public class CircleFTests
// {
// yield return
// new TestCaseData(new CircleF(),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radius: {1}", new Point2(),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radius: {1}", new Vector2(),
// 0)).SetName(
// "The empty circle has the expected string representation using the current culture.");
// yield return new TestCaseData(new CircleF(new Point2(5.1f, -5.123f), 5.4f),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radius: {1}", new Point2(5.1f, -5.123f),
// yield return new TestCaseData(new CircleF(new Vector2(5.1f, -5.123f), 5.4f),
// string.Format(CultureInfo.CurrentCulture, "Centre: {0}, Radius: {1}", new Vector2(5.1f, -5.123f),
// 5.4f)).SetName(
// "A non-empty circle has the expected string representation using the current culture.");
// }
@@ -10,9 +10,9 @@ public class OrientedRectangleTests
[Fact]
public void Initializes_oriented_rectangle()
{
var rectangle = new OrientedRectangle(new Point2(1, 2), new SizeF(3, 4), new Matrix3x2(5, 6, 7, 8, 9, 10));
var rectangle = new OrientedRectangle(new Vector2(1, 2), new SizeF(3, 4), new Matrix3x2(5, 6, 7, 8, 9, 10));
Assert.Equal(new Point2(1, 2), rectangle.Center);
Assert.Equal(new Vector2(1, 2), rectangle.Center);
Assert.Equal(new Vector2(3, 4), rectangle.Radii);
Assert.Equal(new Matrix3x2(5, 6, 7, 8, 9, 10), rectangle.Orientation);
CollectionAssert.Equal(
@@ -31,14 +31,14 @@ public class OrientedRectangleTests
new object[]
{
"empty compared with empty is true",
new OrientedRectangle(Point2.Zero, SizeF.Empty, Matrix3x2.Identity),
new OrientedRectangle(Point2.Zero, SizeF.Empty, Matrix3x2.Identity)
new OrientedRectangle(Vector2.Zero, SizeF.Empty, Matrix3x2.Identity),
new OrientedRectangle(Vector2.Zero, SizeF.Empty, Matrix3x2.Identity)
},
new object[]
{
"initialized compared with initialized true",
new OrientedRectangle(new Point2(1, 2), new SizeF(3, 4), new Matrix3x2(5, 6, 7, 8, 9, 10)),
new OrientedRectangle(new Point2(1, 2), new SizeF(3, 4), new Matrix3x2(5, 6, 7, 8, 9, 10))
new OrientedRectangle(new Vector2(1, 2), new SizeF(3, 4), new Matrix3x2(5, 6, 7, 8, 9, 10)),
new OrientedRectangle(new Vector2(1, 2), new SizeF(3, 4), new Matrix3x2(5, 6, 7, 8, 9, 10))
}
};
@@ -57,29 +57,29 @@ public class OrientedRectangleTests
[Fact]
public void Center_point_is_not_translated()
{
var rectangle = new OrientedRectangle(new Point2(1, 2), new SizeF(), Matrix3x2.Identity);
var rectangle = new OrientedRectangle(new Vector2(1, 2), new SizeF(), Matrix3x2.Identity);
var transform = Matrix3x2.Identity;
var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(1, 2), result.Center);
Assert.Equal(new Vector2(1, 2), result.Center);
}
[Fact]
public void Center_point_is_translated()
{
var rectangle = new OrientedRectangle(new Point2(0, 0), new SizeF(), new Matrix3x2());
var rectangle = new OrientedRectangle(new Vector2(0, 0), new SizeF(), new Matrix3x2());
var transform = Matrix3x2.CreateTranslation(1, 2);
var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(1, 2), result.Center);
Assert.Equal(new Vector2(1, 2), result.Center);
}
[Fact]
public void Radii_is_not_changed_by_identity_transform()
{
var rectangle = new OrientedRectangle(new Point2(), new SizeF(10, 20), new Matrix3x2());
var rectangle = new OrientedRectangle(new Vector2(), new SizeF(10, 20), new Matrix3x2());
var transform = Matrix3x2.Identity;
var result = OrientedRectangle.Transform(rectangle, ref transform);
@@ -90,7 +90,7 @@ public class OrientedRectangleTests
[Fact]
public void Radii_is_not_changed_by_translation()
{
var rectangle = new OrientedRectangle(new Point2(1, 2), new SizeF(10, 20), new Matrix3x2());
var rectangle = new OrientedRectangle(new Vector2(1, 2), new SizeF(10, 20), new Matrix3x2());
var transform = Matrix3x2.CreateTranslation(1, 2);
var result = OrientedRectangle.Transform(rectangle, ref transform);
@@ -101,12 +101,12 @@ public class OrientedRectangleTests
[Fact]
public void Orientation_is_rotated_45_degrees_left()
{
var rectangle = new OrientedRectangle(new Point2(), new SizeF(), Matrix3x2.Identity);
var rectangle = new OrientedRectangle(new Vector2(), new SizeF(), Matrix3x2.Identity);
var transform = Matrix3x2.CreateRotationZ(MathHelper.PiOver4);
var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(), result.Center);
Assert.Equal(new Vector2(), result.Center);
Assert.Equal(new Vector2(), result.Radii);
Assert.Equal(Matrix3x2.CreateRotationZ(MathHelper.PiOver4), result.Orientation);
}
@@ -114,13 +114,13 @@ public class OrientedRectangleTests
[Fact]
public void Orientation_is_rotated_to_45_degrees_from_180()
{
var rectangle = new OrientedRectangle(new Point2(), new SizeF(), Matrix3x2.CreateRotationZ(MathHelper.Pi));
var rectangle = new OrientedRectangle(new Vector2(), new SizeF(), Matrix3x2.CreateRotationZ(MathHelper.Pi));
var transform = Matrix3x2.CreateRotationZ(-3 * MathHelper.PiOver4);
var expectedOrientation = Matrix3x2.CreateRotationZ(MathHelper.PiOver4);
var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(), result.Center);
Assert.Equal(new Vector2(), result.Center);
Assert.Equal(new Vector2(), result.Radii);
Assert.Equal(expectedOrientation.M11, result.Orientation.M11, 6);
Assert.Equal(expectedOrientation.M12, result.Orientation.M12, 6);
@@ -133,7 +133,7 @@ public class OrientedRectangleTests
[Fact]
public void Points_are_same_as_center()
{
var rectangle = new OrientedRectangle(new Point2(1, 2), new SizeF(), Matrix3x2.Identity);
var rectangle = new OrientedRectangle(new Vector2(1, 2), new SizeF(), Matrix3x2.Identity);
var transform = Matrix3x2.Identity;
var result = OrientedRectangle.Transform(rectangle, ref transform);
@@ -152,7 +152,7 @@ public class OrientedRectangleTests
[Fact]
public void Points_are_translated()
{
var rectangle = new OrientedRectangle(new Point2(0, 0), new SizeF(2, 4), Matrix3x2.Identity);
var rectangle = new OrientedRectangle(new Vector2(0, 0), new SizeF(2, 4), Matrix3x2.Identity);
var transform = Matrix3x2.CreateTranslation(10, 20);
var result = OrientedRectangle.Transform(rectangle, ref transform);
@@ -207,7 +207,7 @@ public class OrientedRectangleTests
* :
* :
*/
var rectangle = new OrientedRectangle(new Point2(1, 2), new SizeF(2, 4), Matrix3x2.Identity);
var rectangle = new OrientedRectangle(new Vector2(1, 2), new SizeF(2, 4), Matrix3x2.Identity);
var transform =
Matrix3x2.CreateRotationZ(MathHelper.PiOver2)
*
@@ -5,7 +5,7 @@
//namespace MonoGame.Extended.Tests.Primitives
//{
//
//
// public class Ray2Tests
// {
// public IEnumerable<TestCaseData> ConstructorTestCases
@@ -13,17 +13,17 @@
// get
// {
// yield return
// new TestCaseData(new Point2(), new Vector2()).SetName(
// new TestCaseData(new Vector2(), new Vector2()).SetName(
// "The degenerate ray has the expected position and direction.");
// yield return
// new TestCaseData(new Point2(5, 5), new Vector2(15, 15)).SetName(
// new TestCaseData(new Vector2(5, 5), new Vector2(15, 15)).SetName(
// "A non-degenerate ray has the expected position and direction.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(ConstructorTestCases))]
// public void Constructor(Point2 position, Vector2 direction)
// public void Constructor(Vector2 position, Vector2 direction)
// {
// var ray = new Ray2(position, direction);
// Assert.Equal(position, ray.Position);
@@ -35,10 +35,10 @@
// get
// {
// yield return
// new TestCaseData(new Ray2(), new Point2(), new Vector2()).SetName(
// new TestCaseData(new Ray2(), new Vector2(), new Vector2()).SetName(
// "The degenerate ray has the expected position and direction.");
// yield return
// new TestCaseData(new Ray2(new Point2(5, 5), new Vector2(15, 15)), new Point2(5, 5),
// new TestCaseData(new Ray2(new Vector2(5, 5), new Vector2(15, 15)), new Vector2(5, 5),
// new Vector2(15, 15)).SetName
// (
// "A non-degenerate ray has the expected position and direction.");
@@ -47,14 +47,14 @@
// [Fact]
// [TestCaseSource(nameof(PositionDirectionTestCases))]
// public void PositionDirection(Ray2 ray, Point2 expectedPosition, Vector2 expecetedDirection)
// public void PositionDirection(Ray2 ray, Vector2 expectedPosition, Vector2 expecetedDirection)
// {
// Assert.Equal(expectedPosition, ray.Position);
// Assert.Equal(expecetedDirection, ray.Direction);
// ray.Position.X = 10;
// ray.Position.Y = 10;
// Assert.Equal(new Point2(10, 10), ray.Position);
// Assert.Equal(new Vector2(10, 10), ray.Position);
// ray.Direction.X = -10.123f;
// ray.Direction.Y = 10.123f;
@@ -66,20 +66,20 @@
// get
// {
// yield return
// new TestCaseData(new Ray2(), new BoundingRectangle(), true, Point2.Zero, Point2.Zero).SetName(
// new TestCaseData(new Ray2(), new BoundingRectangle(), true, Vector2.Zero, Vector2.Zero).SetName(
// "The degenerate ray intersects the empty bounding box.");
// yield return
// new TestCaseData(new Ray2(new Point2(-75, -75), new Vector2(75, -75)),
// new BoundingRectangle(new Point2(), new Size2(50, 50)), false, Point2.NaN, Point2.NaN).SetName(
// new TestCaseData(new Ray2(new Vector2(-75, -75), new Vector2(75, -75)),
// new BoundingRectangle(new Vector2(), new Size2(50, 50)), false, Vector2.NaN, Vector2.NaN).SetName(
// "A non-degenerate ray that does not cross a non-empty bounding box does not intersect the bounding box.");
// yield return
// new TestCaseData(new Ray2(new Point2(0, 0), new Vector2(25, 0)), new BoundingRectangle(new Point2(), new Size2(50, 50)),
// true, new Point2(0, 0), new Point2(50, 0)).SetName(
// new TestCaseData(new Ray2(new Vector2(0, 0), new Vector2(25, 0)), new BoundingRectangle(new Vector2(), new Size2(50, 50)),
// true, new Vector2(0, 0), new Vector2(50, 0)).SetName(
// "A non-degenerate ray starting from inside a non-empty bounding box intersects the bounding box.");
// yield return
// new TestCaseData(new Ray2(new Point2(-100, 0), new Vector2(100, 0)),
// new BoundingRectangle(new Point2(), new Size2(50, 50)),
// true, new Point2(-50, 0), new Point2(50, 0)).SetName(
// new TestCaseData(new Ray2(new Vector2(-100, 0), new Vector2(100, 0)),
// new BoundingRectangle(new Vector2(), new Size2(50, 50)),
// true, new Vector2(-50, 0), new Vector2(50, 0)).SetName(
// "A non-degenerate ray crossing a non-empty bounding box intersects the bounding box.");
// }
// }
@@ -87,7 +87,7 @@
// [Fact]
// [TestCaseSource(nameof(IntersectsBoundingRectangleTestCases))]
// public void IntersectsBoundingRectangle(Ray2 ray, BoundingRectangle boundingRectangle, bool expectedResult,
// Point2 firstExpectedIntersectionPoint, Point2 secondExpectedIntersectionPoint)
// Vector2 firstExpectedIntersectionPoint, Vector2 secondExpectedIntersectionPoint)
// {
// float rayNearDistance, rayFarDistance;
// var actualResult = ray.Intersects(boundingRectangle, out rayNearDistance, out rayFarDistance);
@@ -114,14 +114,14 @@
// yield return
// new TestCaseData(new Ray2(), new Ray2(), true).SetName("Two degenerate rays are equal.");
// yield return
// new TestCaseData(new Ray2(new Point2(float.MinValue, float.MaxValue),
// new Vector2(float.MaxValue, float.MinValue)), new Ray2(new Point2(float.MaxValue, float.MinValue),
// new TestCaseData(new Ray2(new Vector2(float.MinValue, float.MaxValue),
// new Vector2(float.MaxValue, float.MinValue)), new Ray2(new Vector2(float.MaxValue, float.MinValue),
// new Vector2(float.MaxValue, float.MinValue)), false).SetName(
// "Two different non-degenerate rays are not equal.");
// yield return
// new TestCaseData(
// new Ray2(new Point2(float.MinValue, float.MaxValue),
// new Vector2(float.MinValue, float.MaxValue)), new Ray2(new Point2(float.MinValue, float.MaxValue),
// new Ray2(new Vector2(float.MinValue, float.MaxValue),
// new Vector2(float.MinValue, float.MaxValue)), new Ray2(new Vector2(float.MinValue, float.MaxValue),
// new Vector2(float.MinValue, float.MaxValue)), true)
// .SetName(
// "Two identical non-degenerate rays are equal.");
@@ -168,12 +168,12 @@
// new TestCaseData(new Ray2(), new Ray2(), true).SetName(
// "Two degenerate rays have the same hash code.");
// yield return
// new TestCaseData(new Ray2(new Point2(50, 50), new Vector2(50, 50)),
// new Ray2(new Point2(50, 50), new Vector2(50, 50)), true).SetName(
// new TestCaseData(new Ray2(new Vector2(50, 50), new Vector2(50, 50)),
// new Ray2(new Vector2(50, 50), new Vector2(50, 50)), true).SetName(
// "Two indentical non-zero points have the same hash code.");
// yield return
// new TestCaseData(new Ray2(new Point2(0, 0), new Vector2(50, 50)),
// new Ray2(new Point2(50, 50), new Vector2(50, 50)), false).SetName(
// new TestCaseData(new Ray2(new Vector2(0, 0), new Vector2(50, 50)),
// new Ray2(new Vector2(50, 50), new Vector2(50, 50)), false).SetName(
// "Two different non-zero points do not have the same hash code.");
// }
// }
@@ -196,11 +196,11 @@
// {
// yield return
// new TestCaseData(new Ray2(),
// string.Format(CultureInfo.CurrentCulture, "Position: {0}, Direction: {1}", new Point2(),
// string.Format(CultureInfo.CurrentCulture, "Position: {0}, Direction: {1}", new Vector2(),
// new Vector2())).SetName(
// "The degenerate ray has the expected string representation using the current culture.");
// yield return new TestCaseData(new Ray2(new Point2(5.1f, -5.123f), new Vector2(0, 1)),
// string.Format(CultureInfo.CurrentCulture, "Position: {0}, Direction: {1}", new Point2(5.1f, -5.123f),
// yield return new TestCaseData(new Ray2(new Vector2(5.1f, -5.123f), new Vector2(0, 1)),
// string.Format(CultureInfo.CurrentCulture, "Position: {0}, Direction: {1}", new Vector2(5.1f, -5.123f),
// new Vector2(0, 1))).SetName(
// "A non-degenerate ray has the expected string representation using the current culture.");
// }
@@ -37,29 +37,29 @@ namespace MonoGame.Extended.Tests.Primitives
[Fact]
public void Center_point_is_not_translated()
{
var rectangle = new RectangleF(new Point2(0, 0), new SizeF(20, 30));
var rectangle = new RectangleF(new Vector2(0, 0), new SizeF(20, 30));
var transform = Matrix3x2.Identity;
var result = RectangleF.Transform(rectangle, ref transform);
Assert.Equal(new Point2(10, 15), result.Center);
Assert.Equal(new Vector2(10, 15), result.Center);
}
[Fact]
public void Center_point_is_translated()
{
var rectangleF = new RectangleF(new Point2(0, 0), new SizeF(20, 30));
var rectangleF = new RectangleF(new Vector2(0, 0), new SizeF(20, 30));
var transform = Matrix3x2.CreateTranslation(1, 2);
var result = RectangleF.Transform(rectangleF, ref transform);
Assert.Equal(new Point2(11, 17), result.Center);
Assert.Equal(new Vector2(11, 17), result.Center);
}
[Fact]
public void Size_is_not_changed_by_identity_transform()
{
var rectangle = new RectangleF(new Point2(0, 0), new SizeF(20, 30));
var rectangle = new RectangleF(new Vector2(0, 0), new SizeF(20, 30));
var transform = Matrix3x2.Identity;
var result = RectangleF.Transform(rectangle, ref transform);
@@ -70,7 +70,7 @@ namespace MonoGame.Extended.Tests.Primitives
[Fact]
public void Size_is_not_changed_by_translation()
{
var rectangle = new RectangleF(new Point2(0, 0), new SizeF(20, 30));
var rectangle = new RectangleF(new Vector2(0, 0), new SizeF(20, 30));
var transform = Matrix3x2.CreateTranslation(1, 2);
var result = RectangleF.Transform(rectangle, ref transform);
@@ -117,7 +117,7 @@ namespace MonoGame.Extended.Tests.Primitives
* :
* :
*/
var rectangle = new RectangleF(new Point2(0, 0), new SizeF(2, 4));
var rectangle = new RectangleF(new Vector2(0, 0), new SizeF(2, 4));
var transform =
Matrix3x2.CreateRotationZ(MathHelper.PiOver2)
*
@@ -11,19 +11,19 @@
// get
// {
// yield return
// new TestCaseData(new Point2(), new Point2()).SetName(
// new TestCaseData(new Vector2(), new Vector2()).SetName(
// "The empty segment has expected starting and ending points.");
// yield return
// new TestCaseData(
// new Point2(float.MaxValue, float.MinValue),
// new Point2(int.MaxValue, int.MinValue)).SetName(
// new Vector2(float.MaxValue, float.MinValue),
// new Vector2(int.MaxValue, int.MinValue)).SetName(
// "A non-empty segment has the expected starting and ending points.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(ConstructorTestCases))]
// public void Constructor(Point2 startingPoint, Point2 endingPoint)
// public void Constructor(Vector2 startingPoint, Vector2 endingPoint)
// {
// var segment = new Segment2(startingPoint, endingPoint);
// Assert.Equal(startingPoint, segment.Start);
@@ -35,21 +35,21 @@
// get
// {
// yield return
// new TestCaseData(new Segment2(), new Point2(), new Point2()).SetName(
// new TestCaseData(new Segment2(), new Vector2(), new Vector2()).SetName(
// "The closest point on the empty segment to the zero point is the zero point.");
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(200, 0)), new Point2(-100, 200),
// new Point2(0, 0)).SetName(
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(200, 0)), new Vector2(-100, 200),
// new Vector2(0, 0)).SetName(
// "The closest point on a non-empty segment to a point which is projected beyond the start of the segment is the segment's starting point.")
// ;
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(200, 0)), new Point2(400, 200),
// new Point2(200, 0)).SetName(
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(200, 0)), new Vector2(400, 200),
// new Vector2(200, 0)).SetName(
// "The closest point on a non-empty segment to a point which is projected beyond the end of the segment is the segment's ending point.")
// ;
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(200, 0)), new Point2(100, 200),
// new Point2(100, 0)).SetName(
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(200, 0)), new Vector2(100, 200),
// new Vector2(100, 0)).SetName(
// "The closest point on a non-empty segment to a point which is projected inside the segment is the projected point.")
// ;
// }
@@ -57,7 +57,7 @@
// [Fact]
// [TestCaseSource(nameof(ClosestPointTestCases))]
// public void ClosestPoint(Segment2 segment, Point2 point, Point2 expectedClosestPoint)
// public void ClosestPoint(Segment2 segment, Vector2 point, Vector2 expectedClosestPoint)
// {
// var actualClosestPoint = segment.ClosestPointTo(point);
// Assert.Equal(expectedClosestPoint, actualClosestPoint);
@@ -68,20 +68,20 @@
// get
// {
// yield return
// new TestCaseData(new Segment2(), new Point2(), 0).SetName(
// new TestCaseData(new Segment2(), new Vector2(), 0).SetName(
// "The squared distance of the zero point to the empty segment is 0.");
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(20, 0)), new Point2(-10, 20), 500)
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(20, 0)), new Vector2(-10, 20), 500)
// .SetName(
// "The squared distance of a point projected beyond the start of a non-empty segment is the squared distance from the segment's starting point to the point.")
// ;
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(20, 0)), new Point2(40, 20), 400)
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(20, 0)), new Vector2(40, 20), 400)
// .SetName(
// "The squared distance of a point projected beyond the end of a non-empty segment is the squared distance from the segment's ending point to the point.")
// ;
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(20, 0)), new Point2(10, 25), 625).SetName
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(20, 0)), new Vector2(10, 25), 625).SetName
// (
// "The squared distance of a point projected inside a non-empty segment is the squared distance from the projected point to the point.")
// ;
@@ -90,7 +90,7 @@
// [Fact]
// [TestCaseSource(nameof(SquaredDistanceToPointTestCases))]
// public void SquaredDistanceToPoint(Segment2 segment, Point2 point,
// public void SquaredDistanceToPoint(Segment2 segment, Vector2 point,
// float expectedDistance)
// {
// var actualDistance = segment.SquaredDistanceTo(point);
@@ -102,20 +102,20 @@
// get
// {
// yield return
// new TestCaseData(new Segment2(), new BoundingRectangle(), true, Point2.Zero).SetName(
// new TestCaseData(new Segment2(), new BoundingRectangle(), true, Vector2.Zero).SetName(
// "The empty segment intersects the empty bounding box.");
// yield return
// new TestCaseData(new Segment2(new Point2(-75, -75), new Point2(75, -75)),
// new BoundingRectangle(new Point2(), new Size2(50, 50)), false, Point2.NaN).SetName(
// new TestCaseData(new Segment2(new Vector2(-75, -75), new Vector2(75, -75)),
// new BoundingRectangle(new Vector2(), new Size2(50, 50)), false, Vector2.NaN).SetName(
// "A non-empty segment outside a non-empty bounding box does not intersect the bounding box.");
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(25, 0)), new BoundingRectangle(new Point2(), new Size2(50, 50)),
// true, new Point2(0, 0)).SetName(
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(25, 0)), new BoundingRectangle(new Vector2(), new Size2(50, 50)),
// true, new Vector2(0, 0)).SetName(
// "A non-empty segment inside a non-empty bounding box intersects the bounding box.");
// yield return
// new TestCaseData(new Segment2(new Point2(-100, 0), new Point2(100, 0)),
// new BoundingRectangle(new Point2(), new Size2(50, 50)),
// true, new Point2(-50, 0)).SetName(
// new TestCaseData(new Segment2(new Vector2(-100, 0), new Vector2(100, 0)),
// new BoundingRectangle(new Vector2(), new Size2(50, 50)),
// true, new Vector2(-50, 0)).SetName(
// "A non-empty segment crossing a non-empty bounding box intersects the bounding box.");
// }
// }
@@ -123,9 +123,9 @@
// [Fact]
// [TestCaseSource(nameof(IntersectsBoundingRectangleTestCases))]
// public void IntersectsBoundingRectangle(Segment2 segment, BoundingRectangle boundingRectangle, bool expectedResult,
// Point2 expectedIntersectionPoint)
// Vector2 expectedIntersectionPoint)
// {
// Point2 actualIntersectionPoint;
// Vector2 actualIntersectionPoint;
// var actualResult = segment.Intersects(boundingRectangle, out actualIntersectionPoint);
// Assert.Equal(expectedResult, actualResult);
@@ -149,15 +149,15 @@
// ;
// yield return
// new TestCaseData(
// new Segment2(new Point2(0, 0), new Point2(float.MaxValue, float.MinValue)),
// new Segment2(new Point2(0, 0),
// new Point2(float.MinValue, float.MaxValue)), false).SetName(
// new Segment2(new Vector2(0, 0), new Vector2(float.MaxValue, float.MinValue)),
// new Segment2(new Vector2(0, 0),
// new Vector2(float.MinValue, float.MaxValue)), false).SetName(
// "Two different non-empty segments are not equal.");
// yield return
// new TestCaseData(
// new Segment2(new Point2(0, 0), new Point2(float.MinValue, float.MaxValue)),
// new Segment2(new Point2(0, 0),
// new Point2(float.MinValue, float.MaxValue)), true).SetName(
// new Segment2(new Vector2(0, 0), new Vector2(float.MinValue, float.MaxValue)),
// new Segment2(new Vector2(0, 0),
// new Vector2(float.MinValue, float.MaxValue)), true).SetName(
// "Two identical non-empty segments are equal.");
// }
// }
@@ -202,12 +202,12 @@
// new TestCaseData(new Segment2(), new Segment2(), true).SetName(
// "Two empty segments have the same hash code.");
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(50, 50)),
// new Segment2(new Point2(0, 0), new Point2(50, 50)), true).SetName(
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(50, 50)),
// new Segment2(new Vector2(0, 0), new Vector2(50, 50)), true).SetName(
// "Two indentical non-empty segments have the same hash code.");
// yield return
// new TestCaseData(new Segment2(new Point2(0, 0), new Point2(50, 50)),
// new Segment2(new Point2(50, 50), new Point2(50, 50)), false).SetName(
// new TestCaseData(new Segment2(new Vector2(0, 0), new Vector2(50, 50)),
// new Segment2(new Vector2(50, 50), new Vector2(50, 50)), false).SetName(
// "Two different non-empty segments do not have the same hash code.");
// }
// }
@@ -230,12 +230,12 @@
// {
// yield return
// new TestCaseData(new Segment2(),
// string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", new Point2(),
// new Point2())).SetName(
// string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", new Vector2(),
// new Vector2())).SetName(
// "The empty segment has the expected string representation using the current culture.");
// yield return new TestCaseData(new Segment2(new Point2(5.1f, -5.123f), new Point2(5.4f, -5.4123f)),
// string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", new Point2(5.1f, -5.123f),
// new Point2(5.4f, -5.4123f))).SetName(
// yield return new TestCaseData(new Segment2(new Vector2(5.1f, -5.123f), new Vector2(5.4f, -5.4123f)),
// string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", new Vector2(5.1f, -5.123f),
// new Vector2(5.4f, -5.4123f))).SetName(
// "A non-empty segment has the expected string representation using the current culture.");
// }
// }
@@ -10,8 +10,8 @@ public class ShapeTests
[Fact]
public void CircCircIntersectionSameCircleTest()
{
IShapeF shape1 = new CircleF(Point2.Zero, 2.0f);
IShapeF shape2 = new CircleF(Point2.Zero, 2.0f);
IShapeF shape1 = new CircleF(Vector2.Zero, 2.0f);
IShapeF shape2 = new CircleF(Vector2.Zero, 2.0f);
Assert.True(shape1.Intersects(shape2));
}
@@ -19,8 +19,8 @@ public class ShapeTests
[Fact]
public void CircCircIntersectionOverlappingTest()
{
IShapeF shape1 = new CircleF(new Point2(1, 2), 2.0f);
IShapeF shape2 = new CircleF(Point2.Zero, 2.0f);
IShapeF shape1 = new CircleF(new Vector2(1, 2), 2.0f);
IShapeF shape2 = new CircleF(Vector2.Zero, 2.0f);
Assert.True(shape1.Intersects(shape2));
}
@@ -28,8 +28,8 @@ public class ShapeTests
[Fact]
public void CircleCircleNotIntersectingTest()
{
IShapeF shape1 = new CircleF(new Point2(5, 5), 2.0f);
IShapeF shape2 = new CircleF(Point2.Zero, 2.0f);
IShapeF shape1 = new CircleF(new Vector2(5, 5), 2.0f);
IShapeF shape2 = new CircleF(Vector2.Zero, 2.0f);
Assert.False(shape1.Intersects(shape2));
}
@@ -40,8 +40,8 @@ public class ShapeTests
[Fact]
public void RectRectSameRectTest()
{
IShapeF shape1 = new RectangleF(Point2.Zero, new SizeF(5, 5));
IShapeF shape2 = new RectangleF(Point2.Zero, new SizeF(5, 5));
IShapeF shape1 = new RectangleF(Vector2.Zero, new SizeF(5, 5));
IShapeF shape2 = new RectangleF(Vector2.Zero, new SizeF(5, 5));
Assert.True(shape1.Intersects(shape2));
}
@@ -49,8 +49,8 @@ public class ShapeTests
[Fact]
public void RectRectIntersectingTest()
{
IShapeF shape1 = new RectangleF(Point2.Zero, new SizeF(5, 5));
IShapeF shape2 = new RectangleF(new Point2(3, 3), new SizeF(5, 5));
IShapeF shape1 = new RectangleF(Vector2.Zero, new SizeF(5, 5));
IShapeF shape2 = new RectangleF(new Vector2(3, 3), new SizeF(5, 5));
Assert.True(shape1.Intersects(shape2));
}
@@ -58,8 +58,8 @@ public class ShapeTests
[Fact]
public void RectRectNotIntersectingTest()
{
IShapeF shape1 = new RectangleF(Point2.Zero, new SizeF(5, 5));
IShapeF shape2 = new RectangleF(new Point2(10, 10), new SizeF(5, 5));
IShapeF shape1 = new RectangleF(Vector2.Zero, new SizeF(5, 5));
IShapeF shape2 = new RectangleF(new Vector2(10, 10), new SizeF(5, 5));
Assert.False(shape1.Intersects(shape2));
}
@@ -67,8 +67,8 @@ public class ShapeTests
[Fact]
public void RectCircContainedTest()
{
IShapeF shape1 = new RectangleF(Point2.Zero, new SizeF(5, 5));
IShapeF shape2 = new CircleF(Point2.Zero, 4);
IShapeF shape1 = new RectangleF(Vector2.Zero, new SizeF(5, 5));
IShapeF shape2 = new CircleF(Vector2.Zero, 4);
Assert.True(shape1.Intersects(shape2));
Assert.True(shape2.Intersects(shape1));
@@ -77,8 +77,8 @@ public class ShapeTests
[Fact]
public void RectCircOnEdgeTest()
{
IShapeF shape1 = new RectangleF(Point2.Zero, new SizeF(5, 5));
IShapeF shape2 = new CircleF(new Point2(5, 0), 4);
IShapeF shape1 = new RectangleF(Vector2.Zero, new SizeF(5, 5));
IShapeF shape2 = new CircleF(new Vector2(5, 0), 4);
Assert.True(shape1.Intersects(shape2));
Assert.True(shape2.Intersects(shape1));
@@ -99,8 +99,8 @@ public class ShapeTests
* :
* :
*/
IShapeF rectangle = new OrientedRectangle(Point2.Zero, new SizeF(1, 1), Matrix3x2.Identity);
var circle = new CircleF(Point2.Zero, 1);
IShapeF rectangle = new OrientedRectangle(Vector2.Zero, new SizeF(1, 1), Matrix3x2.Identity);
var circle = new CircleF(Vector2.Zero, 1);
Assert.True(rectangle.Intersects(circle));
}
@@ -117,8 +117,8 @@ public class ShapeTests
* :
* :
*/
IShapeF rectangle = new OrientedRectangle(Point2.Zero, new SizeF(1, 1), Matrix3x2.Identity);
var circle = new CircleF(new Point2(-2, 1), .99f);
IShapeF rectangle = new OrientedRectangle(Vector2.Zero, new SizeF(1, 1), Matrix3x2.Identity);
var circle = new CircleF(new Vector2(-2, 1), .99f);
Assert.False(rectangle.Intersects(circle));
}
@@ -135,8 +135,8 @@ public class ShapeTests
* * *
* :* *
*/
IShapeF rectangle = new OrientedRectangle(new Point2(-1, 1), new SizeF(1.42f, 1.42f), Matrix3x2.CreateRotationZ(-MathHelper.PiOver4));
var circle = new CircleF(new Point2(1, -1), 1.4f);
IShapeF rectangle = new OrientedRectangle(new Vector2(-1, 1), new SizeF(1.42f, 1.42f), Matrix3x2.CreateRotationZ(-MathHelper.PiOver4));
var circle = new CircleF(new Vector2(1, -1), 1.4f);
Assert.False(rectangle.Intersects(circle));
}
@@ -153,8 +153,8 @@ public class ShapeTests
* :**
* :
*/
IShapeF rectangle = new OrientedRectangle(new Point2(-1, 0), new SizeF(1, 1), Matrix3x2.Identity);
var rect = new RectangleF(new Point2(0.001f, 0), new SizeF(2, 2));
IShapeF rectangle = new OrientedRectangle(new Vector2(-1, 0), new SizeF(1, 1), Matrix3x2.Identity);
var rect = new RectangleF(new Vector2(0.001f, 0), new SizeF(2, 2));
Assert.False(rectangle.Intersects(rect));
}
@@ -171,8 +171,8 @@ public class ShapeTests
* :**
* :
*/
IShapeF rectangle = new OrientedRectangle(new Point2(-1, 0), new SizeF(1, 1), Matrix3x2.Identity);
var rect = new RectangleF(new Point2(0, 0), new SizeF(2, 2));
IShapeF rectangle = new OrientedRectangle(new Vector2(-1, 0), new SizeF(1, 1), Matrix3x2.Identity);
var rect = new RectangleF(new Vector2(0, 0), new SizeF(2, 2));
Assert.True(rectangle.Intersects(rect));
}
@@ -5,7 +5,7 @@
//namespace MonoGame.Extended.Tests.Primitives
//{
//
//
// public class Size2Tests
// {
// public IEnumerable<TestCaseData> ConstructorTestCases
@@ -184,18 +184,18 @@
// get
// {
// yield return
// new TestCaseData(new Size2(), new Point2()).SetName("The empty size converted to a point is the zero point.");
// new TestCaseData(new Size2(), new Vector2()).SetName("The empty size converted to a point is the zero point.");
// yield return
// new TestCaseData(new Size2(float.MinValue, float.MaxValue), new Point2(float.MinValue, float.MaxValue)).SetName(
// new TestCaseData(new Size2(float.MinValue, float.MaxValue), new Vector2(float.MinValue, float.MaxValue)).SetName(
// "A non-empty size converted to a point is the expected point.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(ToPointTestCases))]
// public void ToPoint(Size2 size, Point2 expectedPoint)
// public void ToPoint(Size2 size, Vector2 expectedPoint)
// {
// var actualPoint = (Point2)size;
// var actualPoint = (Vector2)size;
// Assert.Equal(expectedPoint, actualPoint);
// }
@@ -204,16 +204,16 @@
// get
// {
// yield return
// new TestCaseData(new Point2(), new Size2()).SetName("The zero point converted to a size is the empty size.");
// new TestCaseData(new Vector2(), new Size2()).SetName("The zero point converted to a size is the empty size.");
// yield return
// new TestCaseData(new Point2(float.MinValue, float.MaxValue), new Size2(float.MinValue, float.MaxValue)).SetName(
// new TestCaseData(new Vector2(float.MinValue, float.MaxValue), new Size2(float.MinValue, float.MaxValue)).SetName(
// "A non-zero point converted to a size is the expected size.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(FromPointTestCases))]
// public void FromPoint(Point2 point, Size2 expectedSize)
// public void FromPoint(Vector2 point, Size2 expectedSize)
// {
// var actualSize = (Size2)point;
// Assert.Equal(expectedSize, actualSize);