public void Equals_NotEqual_ExpectedFalse() { LineSegment2D lineSegment1 = new LineSegment2D(new Point2D(10, 0), new Point2D(67, 76.21)); LineSegment2D lineSegment2 = new LineSegment2D(new Point2D(-41, 0), new Point2D(0, 98)); Assert.IsFalse(lineSegment1.Equals(lineSegment2)); }
public void Equals_DifferentVertexOrder_ExpectedTrue() { LineSegment2D lineSegment1 = new LineSegment2D(new Point2D(10, 0), new Point2D(67, 76.21)); LineSegment2D lineSegment2 = new LineSegment2D(new Point2D(67, 76.21), new Point2D(10, 0)); Assert.That(lineSegment1.Equals(lineSegment2)); }
public void Equals_SameVertexPositions_ExpectedTrue() { LineSegment2D lineSegment1 = new LineSegment2D(new Point2D(10, 0), new Point2D(67, 76.21)); LineSegment2D lineSegment2 = new LineSegment2D(new Point2D(10, 0), new Point2D(67, 76.21)); Assert.That(lineSegment1.Equals(lineSegment2)); }
public void IntersectingShapeWithLineSegment_IdenticalSegments_ExpectedLineSegment() { LineSegment2D lineSegment1 = new LineSegment2D(new Point2D(0, 0), new Point2D(10, 10)); LineSegment2D lineSegment2 = new LineSegment2D(new Point2D(0, 0), new Point2D(10, 10)); Shape2D expectedIntersectingShape = new LineSegment2D(new Point2D(0, 0), new Point2D(10, 10)); Shape2D actualIntersectingShape = lineSegment1.IntersectingShape(lineSegment2); Assert.That(expectedIntersectingShape.Equals(actualIntersectingShape)); }
public void IntersectingShapeWithRay_LineSegmentPartiallyInsideRay_ExpectedShortLineSegment(double p1x, double p1y, double p2x, double p2y) { LineSegment2D lineSegment = new LineSegment2D(new Point2D(p1x, p1y), new Point2D(p2x, p2y)); Ray2D ray = new Ray2D(new Point2D(0, 0), new Point2D(10, 10)); Shape2D expectedIntersectingShape = new LineSegment2D(new Point2D(0, 0), new Point2D(5, 5)); Shape2D actualIntersectingShape = lineSegment.IntersectingShape(ray); Assert.That(expectedIntersectingShape.Equals(actualIntersectingShape)); }
public void IntersectingShapeWithRay_LineSegmentFullyInsideRay_ExpectedLineSegment() { LineSegment2D lineSegment = new LineSegment2D(new Point2D(15, 15), new Point2D(20, 20)); Ray2D ray = new Ray2D(new Point2D(0, 0), new Point2D(10, 10)); Shape2D expectedIntersectingShape = new LineSegment2D(new Point2D(15, 15), new Point2D(20, 20)); Shape2D actualIntersectingShape = lineSegment.IntersectingShape(ray); Assert.That(expectedIntersectingShape.Equals(actualIntersectingShape)); }
public void Test() { var a1 = new Vector2D(10, 20); var a2 = new Vector2D(30, 40); var seg = new LineSegment2D(a1, a2); Assert.AreEqual(a1, seg.Start); Assert.AreEqual(a2, seg.Stop); Assert.AreEqual(10, seg.Bounds.Left); Assert.AreEqual(30, seg.Bounds.Right); Assert.AreEqual(20, seg.Bounds.Top); Assert.AreEqual(40, seg.Bounds.Bottom); var seg2 = new LineSegment2D(seg); Assert.AreEqual(seg, seg2); var seg3 = new LineSegment2D(a1, a1); Assert.AreEqual(seg.GetHashCode(), seg2.GetHashCode()); Assert.AreNotEqual(seg3.GetHashCode(), seg2.GetHashCode()); Assert.AreNotEqual(seg3.GetHashCode(), seg.GetHashCode()); var eq = seg.Equals(seg2); Assert.IsTrue(eq); eq = seg.Equals(seg3); Assert.IsFalse(eq); var seg4 = new LineSegment2D(a2, a2); eq = seg.Equals(seg4); Assert.IsFalse(eq); var str = seg.ToString(); var exp = "LineSegment: Start = " + a1 + " Stop = " + a2; Assert.AreEqual(exp, str); }
public void EqualityComparisonFalseAgainstNull() { var line = new LineSegment2D(default(Point2D), new Point2D(1, 1)); Assert.IsFalse(line.Equals(null)); }