[15554] | 1 | using System;
|
---|
| 2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 3 | using HeuristicLab.Problems.BinPacking3D.Geometry;
|
---|
| 4 |
|
---|
| 5 | namespace HeuristicLab.Problems.BinPacking._3D.Geometry.Test {
|
---|
| 6 | [TestClass]
|
---|
| 7 | public class Edge3DTest {
|
---|
| 8 |
|
---|
| 9 | Edge3D _edge1;
|
---|
| 10 | Edge3D _edge2;
|
---|
| 11 | Edge3D _edge3;
|
---|
| 12 | Edge3D _edge4;
|
---|
| 13 | Edge3D _edge5;
|
---|
| 14 | Edge3D _edge6;
|
---|
| 15 | Edge3D _edge7;
|
---|
| 16 | Edge3D _edge8;
|
---|
| 17 | Edge3D _edge9;
|
---|
| 18 |
|
---|
| 19 | Vector3D _point1;
|
---|
| 20 | Vector3D _point2;
|
---|
| 21 | Vector3D _point3;
|
---|
| 22 | Vector3D _point4;
|
---|
| 23 | Vector3D _point5;
|
---|
| 24 | Vector3D _point6;
|
---|
| 25 |
|
---|
| 26 | [TestInitialize]
|
---|
| 27 | public void Initialize() {
|
---|
| 28 | _edge1 = new Edge3D(new Vector3D(0, 0, 0), new Vector3D(10, 0, 0));
|
---|
| 29 | _edge2 = new Edge3D(new Vector3D(0, 0, 0), new Vector3D(0, 10, 0));
|
---|
| 30 | _edge3 = new Edge3D(new Vector3D(0, 0, 0), new Vector3D(0, 0, 10));
|
---|
| 31 |
|
---|
| 32 | _edge4 = new Edge3D(new Vector3D(-10, 2, 2), new Vector3D(10, 2, 2));
|
---|
| 33 | _edge5 = new Edge3D(new Vector3D(2, -10, 2), new Vector3D(2, 10, 2));
|
---|
| 34 | _edge6 = new Edge3D(new Vector3D(2, 2, -10), new Vector3D(2, 2, 10));
|
---|
| 35 |
|
---|
| 36 | _edge7 = new Edge3D(new Vector3D(-10, 5, 5), new Vector3D(10, 5, 5));
|
---|
| 37 | _edge8 = new Edge3D(new Vector3D(5, -10, 5), new Vector3D(5, 10, 5));
|
---|
| 38 | _edge9 = new Edge3D(new Vector3D(5, 5, -10), new Vector3D(5, 5, 10));
|
---|
| 39 |
|
---|
| 40 | _point1 = new Vector3D(3, 0, 0);
|
---|
| 41 | _point2 = new Vector3D(0, 3, 0);
|
---|
| 42 | _point3 = new Vector3D(0, 0, 3);
|
---|
| 43 |
|
---|
| 44 | _point4 = new Vector3D(5, 5, 5);
|
---|
| 45 | _point5 = new Vector3D(2, 2, 2);
|
---|
| 46 | _point6 = new Vector3D(0, 0, 0);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | [TestMethod]
|
---|
| 50 | [TestCategory("Problems.BinPacking.3D")]
|
---|
| 51 | [TestProperty("Time", "short")]
|
---|
| 52 | public void TestConstructors() {
|
---|
| 53 | var e1 = new Edge3D() {
|
---|
| 54 | Start = new Vector3D(10, 0, 0),
|
---|
| 55 | End = new Vector3D(10, 5, 0)
|
---|
| 56 | };
|
---|
| 57 | var e2 = new Edge3D(new Vector3D(10, 0, 0), new Vector3D(10, 5, 0));
|
---|
| 58 | var e3 = new Edge3D(new BinPacking3D.PackingPosition(0, 10, 0, 0), new BinPacking3D.PackingPosition(0, 10, 5, 0));
|
---|
| 59 |
|
---|
| 60 | Assert.AreEqual(e1.Start, e2.Start);
|
---|
| 61 | Assert.AreEqual(e1.End, e2.End);
|
---|
| 62 | Assert.AreEqual(e1.Start, e3.Start);
|
---|
| 63 | Assert.AreEqual(e1.End, e3.End);
|
---|
| 64 | Assert.AreEqual(e3.Start, e2.Start);
|
---|
| 65 | Assert.AreEqual(e3.End, e2.End);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | [TestMethod]
|
---|
| 69 | [TestCategory("Problems.BinPacking.3D")]
|
---|
| 70 | [TestProperty("Time", "short")]
|
---|
| 71 | public void TestLiesOn() {
|
---|
| 72 | Assert.IsTrue(_edge1.LiesOn(_point1));
|
---|
| 73 | Assert.IsFalse(_edge1.LiesOn(_point4));
|
---|
| 74 | Assert.IsTrue(_edge3.LiesOn(_point6));
|
---|
| 75 | Assert.IsFalse(_edge2.LiesOn(_point5));
|
---|
| 76 | Assert.IsTrue(_edge4.LiesOn(_point5));
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | [TestMethod]
|
---|
| 80 | [TestCategory("Problems.BinPacking.3D")]
|
---|
| 81 | [TestProperty("Time", "short")]
|
---|
| 82 | public void TestIntersects() {
|
---|
| 83 | Assert.IsNull(_edge1.Intersects(_edge4));
|
---|
| 84 | Assert.IsNull(_edge4.Intersects(_edge1));
|
---|
| 85 | Assert.IsNull(_edge7.Intersects(_edge5));
|
---|
| 86 | Assert.IsNull(_edge8.Intersects(_edge6));
|
---|
| 87 |
|
---|
| 88 | Assert.IsNotNull(_edge1.Intersects(_edge2));
|
---|
| 89 | Assert.AreEqual(_point6, _edge1.Intersects(_edge2));
|
---|
| 90 | Assert.IsNotNull(_edge5.Intersects(_edge5));
|
---|
| 91 | Assert.AreEqual(_point5, _edge5.Intersects(_edge6));
|
---|
| 92 | Assert.IsNotNull(_edge8.Intersects(_edge7));
|
---|
| 93 | Assert.AreEqual(_point4, _edge8.Intersects(_edge7));
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | [TestMethod]
|
---|
| 97 | [TestCategory("Problems.BinPacking.3D")]
|
---|
| 98 | [TestProperty("Time", "short")]
|
---|
| 99 | public void TestStaticIntersects() {
|
---|
| 100 | Assert.IsNull(Edge3D.Intersects(_edge1, _edge4));
|
---|
| 101 | Assert.IsNull(Edge3D.Intersects(_edge4, _edge1));
|
---|
| 102 | Assert.IsNull(Edge3D.Intersects(_edge7, _edge5));
|
---|
| 103 | Assert.IsNull(Edge3D.Intersects(_edge8, _edge6));
|
---|
| 104 |
|
---|
| 105 | Assert.IsNotNull(Edge3D.Intersects(new Edge3D(new Vector3D(0, 0, 0), new Vector3D(10, 0, 0)), new Edge3D(new Vector3D(0, 0, 0), new Vector3D(0, 10, 0))));
|
---|
| 106 | Assert.IsNotNull(Edge3D.Intersects(new Edge3D(new Vector3D(-10, 0, 0), new Vector3D(0, 0, 0)), new Edge3D(new Vector3D(0, -10, 0), new Vector3D(0, 0, 0))));
|
---|
| 107 |
|
---|
| 108 | Assert.IsNotNull(Edge3D.Intersects(_edge1, _edge2));
|
---|
| 109 | Assert.AreEqual(_point6, Edge3D.Intersects(_edge1, _edge2));
|
---|
| 110 | Assert.IsNotNull(Edge3D.Intersects(_edge5, _edge5));
|
---|
| 111 | Assert.AreEqual(_point5, Edge3D.Intersects(_edge5, _edge6));
|
---|
| 112 | Assert.IsNotNull(Edge3D.Intersects(_edge8, _edge7));
|
---|
| 113 | Assert.AreEqual(_point4, Edge3D.Intersects(_edge8, _edge7));
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 | }
|
---|
| 117 |
|
---|