1 | using System;
|
---|
2 | using System.Text;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using System.Linq;
|
---|
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
6 | using HeuristicLab.Problems.BinPacking3D.Geometry;
|
---|
7 | using HeuristicLab.Problems.BinPacking3D.ResidualSpaceCalculation;
|
---|
8 | using HeuristicLab.Problems.BinPacking._3D.Utils.Tests;
|
---|
9 | using HeuristicLab.Problems.BinPacking3D;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.Problems.BinPacking._3D.ResidualSpaceCalculation.Tests {
|
---|
12 | /// <summary>
|
---|
13 | /// Summary description for ResidualSpaceCalculator
|
---|
14 | /// </summary>
|
---|
15 | [TestClass]
|
---|
16 | public class ResidualSpaceCalculatorTest {
|
---|
17 |
|
---|
18 | #region Points, residual spaces, packing positions and items
|
---|
19 |
|
---|
20 | Vector3D _point1;
|
---|
21 | Vector3D _point2;
|
---|
22 | Vector3D _point3;
|
---|
23 | Vector3D _point4;
|
---|
24 | Vector3D _point5;
|
---|
25 | Vector3D _point6;
|
---|
26 | Vector3D _point7;
|
---|
27 | Vector3D _point8;
|
---|
28 | Vector3D _point9;
|
---|
29 | Vector3D _point10;
|
---|
30 | Vector3D _point11;
|
---|
31 |
|
---|
32 | ResidualSpace _rs1;
|
---|
33 | ResidualSpace _rs2;
|
---|
34 | ResidualSpace _rs3;
|
---|
35 | ResidualSpace _rs4;
|
---|
36 | ResidualSpace _rs5;
|
---|
37 | ResidualSpace _rs6;
|
---|
38 | ResidualSpace _rs7;
|
---|
39 |
|
---|
40 | BinPacking3D.PackingPosition _pos1;
|
---|
41 | BinPacking3D.PackingPosition _pos2;
|
---|
42 | BinPacking3D.PackingPosition _pos3;
|
---|
43 | BinPacking3D.PackingPosition _pos4;
|
---|
44 | BinPacking3D.PackingPosition _pos5;
|
---|
45 | BinPacking3D.PackingPosition _pos6;
|
---|
46 | BinPacking3D.PackingPosition _pos7;
|
---|
47 | BinPacking3D.PackingPosition _pos8;
|
---|
48 | BinPacking3D.PackingPosition _pos9;
|
---|
49 | BinPacking3D.PackingPosition _pos10;
|
---|
50 | BinPacking3D.PackingPosition _pos11;
|
---|
51 |
|
---|
52 | BinPacking3D.PackingItem _item1;
|
---|
53 | BinPacking3D.PackingItem _item2;
|
---|
54 | BinPacking3D.PackingItem _item3;
|
---|
55 | BinPacking3D.PackingItem _item4;
|
---|
56 | BinPacking3D.PackingItem _item5;
|
---|
57 | BinPacking3D.PackingItem _item6;
|
---|
58 | BinPacking3D.PackingItem _item7;
|
---|
59 |
|
---|
60 | BinPacking3D.BinPacking3D _bp1;
|
---|
61 | BinPacking3D.BinPacking3D _bp2;
|
---|
62 | BinPacking3D.BinPacking3D _bp3;
|
---|
63 | #endregion
|
---|
64 |
|
---|
65 | IResidualSpaceCalculator _calculator;
|
---|
66 |
|
---|
67 | [TestInitialize]
|
---|
68 | public void Initialize() {
|
---|
69 | _calculator = ResidualSpaceCalculatorFactory.CreateCalculator();
|
---|
70 | _point1 = new Vector3D(0, 0, 0);
|
---|
71 | _point2 = new Vector3D(0, 10, 10);
|
---|
72 | _point3 = new Vector3D(10, 0, 10);
|
---|
73 | _point4 = new Vector3D(10, 10, 0);
|
---|
74 |
|
---|
75 | _point5 = new Vector3D(10, 20, 20);
|
---|
76 | _point6 = new Vector3D(20, 10, 20);
|
---|
77 | _point7 = new Vector3D(20, 20, 10);
|
---|
78 |
|
---|
79 | _point8 = new Vector3D(0, 20, 20);
|
---|
80 | _point9 = new Vector3D(20, 0, 20);
|
---|
81 | _point10 = new Vector3D(20, 20, 0);
|
---|
82 | _point11 = new Vector3D(20, 20, 20);
|
---|
83 |
|
---|
84 | _rs1 = new ResidualSpace(5, 5, 5);
|
---|
85 | _rs2 = new ResidualSpace(10, 10, 10);
|
---|
86 | _rs3 = new ResidualSpace(20, 20, 20);
|
---|
87 | _rs4 = new ResidualSpace(30, 30, 30);
|
---|
88 | _rs5 = new ResidualSpace(10, 20, 20);
|
---|
89 | _rs6 = new ResidualSpace(20, 10, 20);
|
---|
90 | _rs7 = new ResidualSpace(20, 20, 10);
|
---|
91 |
|
---|
92 | _pos1 = _point1.ToPackingPosition(0);
|
---|
93 | _pos2 = _point2.ToPackingPosition(0);
|
---|
94 | _pos3 = _point3.ToPackingPosition(0);
|
---|
95 | _pos4 = _point4.ToPackingPosition(0);
|
---|
96 | _pos5 = _point5.ToPackingPosition(0);
|
---|
97 | _pos6 = _point6.ToPackingPosition(0);
|
---|
98 | _pos7 = _point7.ToPackingPosition(0);
|
---|
99 | _pos8 = _point8.ToPackingPosition(0);
|
---|
100 | _pos9 = _point9.ToPackingPosition(0);
|
---|
101 | _pos10 = _point10.ToPackingPosition(0);
|
---|
102 | _pos11 = _point11.ToPackingPosition(0);
|
---|
103 |
|
---|
104 | _item1 = _rs1.ToPackingItem();
|
---|
105 | _item2 = _rs2.ToPackingItem();
|
---|
106 | _item3 = _rs3.ToPackingItem();
|
---|
107 | _item4 = _rs4.ToPackingItem();
|
---|
108 | _item5 = _rs5.ToPackingItem();
|
---|
109 | _item6 = _rs6.ToPackingItem();
|
---|
110 | _item7 = _rs7.ToPackingItem();
|
---|
111 |
|
---|
112 | _bp1 = new BinPacking3D.BinPacking3D(new PackingShape(30, 30, 30));
|
---|
113 | _bp1.PackItem(0, _item4, _pos2);
|
---|
114 | _bp2 = new BinPacking3D.BinPacking3D(new PackingShape(30, 30, 30));
|
---|
115 | _bp2.PackItem(0, _item4, _pos5);
|
---|
116 | _bp3 = new BinPacking3D.BinPacking3D(new PackingShape(30, 30, 30));
|
---|
117 | _bp3.PackItem(0, _item4, _pos4);
|
---|
118 | }
|
---|
119 |
|
---|
120 | [TestMethod]
|
---|
121 | [TestCategory("Problems.BinPacking.3D")]
|
---|
122 | [TestProperty("Time", "short")]
|
---|
123 | public void TestOverlapsX() {
|
---|
124 | Assert.IsFalse( (bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsX", new object[] { _point1, _rs1, _pos3, _item1 }));
|
---|
125 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsX", new object[] { _point3, _rs1, _pos1, _item1 }));
|
---|
126 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsX", new object[] { _point3, _rs1, _pos6, _item1 }));
|
---|
127 |
|
---|
128 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsX", new object[] { _point1, _rs3, _pos3, _item3 }));
|
---|
129 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsX", new object[] { _point3, _rs3, _pos1, _item3 }));
|
---|
130 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsX", new object[] { _point1, _rs3, _pos1, _item2 }));
|
---|
131 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsX", new object[] { _point1, _rs2, _pos1, _item3 }));
|
---|
132 | }
|
---|
133 |
|
---|
134 | [TestMethod]
|
---|
135 | [TestCategory("Problems.BinPacking.3D")]
|
---|
136 | [TestProperty("Time", "short")]
|
---|
137 | public void TestOverlapsY() {
|
---|
138 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsY", new object[] { _point1, _rs1, _pos2, _item1 }));
|
---|
139 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsY", new object[] { _point2, _rs1, _pos1, _item1 }));
|
---|
140 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsY", new object[] { _point2, _rs1, _pos5, _item1 }));
|
---|
141 |
|
---|
142 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsY", new object[] { _point1, _rs3, _pos2, _item3 }));
|
---|
143 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsY", new object[] { _point2, _rs3, _pos1, _item3 }));
|
---|
144 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsY", new object[] { _point1, _rs3, _pos1, _item2 }));
|
---|
145 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsY", new object[] { _point1, _rs2, _pos1, _item3 }));
|
---|
146 | }
|
---|
147 |
|
---|
148 | [TestMethod]
|
---|
149 | [TestCategory("Problems.BinPacking.3D")]
|
---|
150 | [TestProperty("Time", "short")]
|
---|
151 | public void TestOverlapsZ() {
|
---|
152 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsZ", new object[] { _point1, _rs1, _pos2, _item1 }));
|
---|
153 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsZ", new object[] { _point2, _rs1, _pos1, _item1 }));
|
---|
154 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsZ", new object[] { _point2, _rs1, _pos5, _item1 }));
|
---|
155 |
|
---|
156 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsZ", new object[] { _point1, _rs3, _pos2, _item3 }));
|
---|
157 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsZ", new object[] { _point2, _rs3, _pos1, _item3 }));
|
---|
158 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsZ", new object[] { _point1, _rs3, _pos1, _item2 }));
|
---|
159 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsZ", new object[] { _point1, _rs2, _pos1, _item3 }));
|
---|
160 | }
|
---|
161 |
|
---|
162 | [TestMethod]
|
---|
163 | [TestCategory("Problems.BinPacking.3D")]
|
---|
164 | [TestProperty("Time", "short")]
|
---|
165 | public void TestOverlapsOnRight() {
|
---|
166 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs1, _pos9, _item1 }));
|
---|
167 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs1, _pos10, _item1 }));
|
---|
168 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs1, _pos11, _item1 }));
|
---|
169 |
|
---|
170 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point9, _rs1, _pos1, _item1 }));
|
---|
171 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point10, _rs1, _pos1, _item1 }));
|
---|
172 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point11, _rs1, _pos1, _item1 }));
|
---|
173 |
|
---|
174 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs4, _pos9, _item4 }));
|
---|
175 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs4, _pos10, _item4 }));
|
---|
176 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs4, _pos11, _item4 }));
|
---|
177 |
|
---|
178 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs3, _pos9, _item3 }));
|
---|
179 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs3, _pos10, _item3 }));
|
---|
180 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point1, _rs3, _pos11, _item3 }));
|
---|
181 |
|
---|
182 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point9, _rs3, _pos1, _item3 }));
|
---|
183 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point10, _rs3, _pos1, _item3 }));
|
---|
184 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsOnRight", new object[] { _point11, _rs3, _pos1, _item3 }));
|
---|
185 | }
|
---|
186 |
|
---|
187 | [TestMethod]
|
---|
188 | [TestCategory("Problems.BinPacking.3D")]
|
---|
189 | [TestProperty("Time", "short")]
|
---|
190 | public void TestOverlapsInFront() {
|
---|
191 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs1, _pos9, _item1 }));
|
---|
192 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs1, _pos8, _item1 }));
|
---|
193 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs1, _pos11, _item1 }));
|
---|
194 |
|
---|
195 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point9, _rs1, _pos1, _item1 }));
|
---|
196 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point8, _rs1, _pos1, _item1 }));
|
---|
197 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point11, _rs1, _pos1, _item1 }));
|
---|
198 |
|
---|
199 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs4, _pos9, _item4 }));
|
---|
200 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs4, _pos8, _item4 }));
|
---|
201 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs4, _pos11, _item4 }));
|
---|
202 |
|
---|
203 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs3, _pos9, _item3 }));
|
---|
204 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs3, _pos8, _item3 }));
|
---|
205 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point1, _rs3, _pos11, _item3 }));
|
---|
206 |
|
---|
207 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point9, _rs3, _pos1, _item3 }));
|
---|
208 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point8, _rs3, _pos1, _item3 }));
|
---|
209 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsInFront", new object[] { _point11, _rs3, _pos1, _item3 }));
|
---|
210 | }
|
---|
211 |
|
---|
212 | [TestMethod]
|
---|
213 | [TestCategory("Problems.BinPacking.3D")]
|
---|
214 | [TestProperty("Time", "short")]
|
---|
215 | public void TestOverlapsAbove() {
|
---|
216 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs1, _pos8, _item1 }));
|
---|
217 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs1, _pos10, _item1 }));
|
---|
218 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs1, _pos11, _item1 }));
|
---|
219 |
|
---|
220 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point8, _rs1, _pos1, _item1 }));
|
---|
221 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point10, _rs1, _pos1, _item1 }));
|
---|
222 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point11, _rs1, _pos1, _item1 }));
|
---|
223 |
|
---|
224 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs4, _pos8, _item4 }));
|
---|
225 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs4, _pos10, _item4 }));
|
---|
226 | Assert.IsTrue((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs4, _pos11, _item4 }));
|
---|
227 |
|
---|
228 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs3, _pos8, _item3 }));
|
---|
229 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs3, _pos10, _item3 }));
|
---|
230 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point1, _rs3, _pos11, _item3 }));
|
---|
231 |
|
---|
232 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point8, _rs3, _pos1, _item3 }));
|
---|
233 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point10, _rs3, _pos1, _item3 }));
|
---|
234 | Assert.IsFalse((bool)TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "OverlapsAbove", new object[] { _point11, _rs3, _pos1, _item3 }));
|
---|
235 | }
|
---|
236 |
|
---|
237 | [TestMethod]
|
---|
238 | [TestCategory("Problems.BinPacking.3D")]
|
---|
239 | [TestProperty("Time", "short")]
|
---|
240 | public void TestLimitResidualSpaceOnRight() {
|
---|
241 |
|
---|
242 | ResidualSpace rs1 = _rs4.Clone() as ResidualSpace;
|
---|
243 | ResidualSpace rs2 = _rs4.Clone() as ResidualSpace;
|
---|
244 | ResidualSpace rs3 = _rs4.Clone() as ResidualSpace;
|
---|
245 | ResidualSpace rs4 = _rs4.Clone() as ResidualSpace;
|
---|
246 | ResidualSpace rs5 = _rs4.Clone() as ResidualSpace;
|
---|
247 | rs4.Height = 20;
|
---|
248 | rs5.Height = 10;
|
---|
249 |
|
---|
250 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceOnRight", new object[] { _bp1, _point1, rs1 });
|
---|
251 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceOnRight", new object[] { _bp2, _point1, rs2 });
|
---|
252 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceOnRight", new object[] { _bp3, _point1, rs3 });
|
---|
253 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceOnRight", new object[] { _bp2, _point1, rs4 });
|
---|
254 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceOnRight", new object[] { _bp3, _point1, rs5 });
|
---|
255 | Assert.AreEqual(30, rs1.Width);
|
---|
256 | Assert.AreEqual(10, rs2.Width);
|
---|
257 | Assert.AreEqual(10, rs3.Width);
|
---|
258 | Assert.AreEqual(30, rs4.Width);
|
---|
259 | Assert.AreEqual(30, rs5.Width);
|
---|
260 | }
|
---|
261 |
|
---|
262 | [TestMethod]
|
---|
263 | [TestCategory("Problems.BinPacking.3D")]
|
---|
264 | [TestProperty("Time", "short")]
|
---|
265 | public void TestLimitResidualSpaceInFront() {
|
---|
266 | ResidualSpace rs1 = _rs4.Clone() as ResidualSpace;
|
---|
267 | ResidualSpace rs2 = _rs4.Clone() as ResidualSpace;
|
---|
268 | ResidualSpace rs3 = _rs4.Clone() as ResidualSpace;
|
---|
269 | ResidualSpace rs4 = _rs4.Clone() as ResidualSpace;
|
---|
270 | ResidualSpace rs5 = _rs4.Clone() as ResidualSpace;
|
---|
271 | rs4.Height = 20;
|
---|
272 | rs5.Height = 10;
|
---|
273 |
|
---|
274 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceInFront", new object[] { _bp1, _point1, rs1 });
|
---|
275 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceInFront", new object[] { _bp2, _point1, rs2 });
|
---|
276 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceInFront", new object[] { _bp3, _point1, rs3 });
|
---|
277 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceInFront", new object[] { _bp2, _point1, rs4 });
|
---|
278 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceInFront", new object[] { _bp1, _point1, rs5 });
|
---|
279 | Assert.AreEqual(10, rs1.Depth);
|
---|
280 | Assert.AreEqual(20, rs2.Depth);
|
---|
281 | Assert.AreEqual(30, rs3.Depth);
|
---|
282 | Assert.AreEqual(30, rs4.Depth);
|
---|
283 | Assert.AreEqual(30, rs5.Depth);
|
---|
284 | }
|
---|
285 |
|
---|
286 | [TestMethod]
|
---|
287 | [TestCategory("Problems.BinPacking.3D")]
|
---|
288 | [TestProperty("Time", "short")]
|
---|
289 | public void TestLimitResidualSpaceAbove() {
|
---|
290 | ResidualSpace rs1 = _rs4.Clone() as ResidualSpace;
|
---|
291 | ResidualSpace rs2 = _rs4.Clone() as ResidualSpace;
|
---|
292 | ResidualSpace rs3 = _rs4.Clone() as ResidualSpace;
|
---|
293 |
|
---|
294 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceAbove", new object[] { _bp1, _point1, rs1 });
|
---|
295 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceAbove", new object[] { _bp2, _point1, rs2 });
|
---|
296 | TestUtils.InvokeMethod(_calculator.GetType(), _calculator, "LimitResidualSpaceAbove", new object[] { _bp3, _point1, rs3 });
|
---|
297 | Assert.AreEqual(10, rs1.Height);
|
---|
298 | Assert.AreEqual(20, rs2.Height);
|
---|
299 | Assert.AreEqual(10, rs3.Height);
|
---|
300 | }
|
---|
301 |
|
---|
302 | [TestMethod]
|
---|
303 | [TestCategory("Problems.BinPacking.3D")]
|
---|
304 | [TestProperty("Time", "short")]
|
---|
305 | public void TestCalculateResidualSpaces() {
|
---|
306 | var residualSpaces = _calculator.CalculateResidualSpaces(_bp2, _point1).ToList();
|
---|
307 | Assert.AreEqual(3, residualSpaces.Count);
|
---|
308 | Assert.AreEqual(10, residualSpaces[0].Width);
|
---|
309 | Assert.AreEqual(30, residualSpaces[0].Height);
|
---|
310 | Assert.AreEqual(30, residualSpaces[0].Depth);
|
---|
311 | Assert.AreEqual(30, residualSpaces[1].Width);
|
---|
312 | Assert.AreEqual(30, residualSpaces[1].Height);
|
---|
313 | Assert.AreEqual(20, residualSpaces[1].Depth);
|
---|
314 | Assert.AreEqual(30, residualSpaces[2].Width);
|
---|
315 | Assert.AreEqual(20, residualSpaces[2].Height);
|
---|
316 | Assert.AreEqual(30, residualSpaces[2].Depth);
|
---|
317 | }
|
---|
318 | }
|
---|
319 | }
|
---|