18
|
1 // This file (UnitEquipmentItemUtilTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
|
|
4
|
|
5 using System;
|
|
6 using NUnit.Framework;
|
|
7 using IBBoard.Limits;
|
|
8 using IBBoard.WarFoundry.API.Objects;
|
|
9 using IBBoard.WarFoundry.API.Objects.Mock;
|
|
10
|
|
11 namespace IBBoard.WarFoundry.API.Util
|
|
12 {
|
|
13 [TestFixture()]
|
|
14 public class UnitEquipmentUtilTest
|
|
15 {
|
26
|
16 private const string SLOT_NAME = "slot";
|
|
17
|
18
|
18 [Test()]
|
24
|
19 public void TestGetEquipmentCountsForFixedLimitItemOnDefaultSlot()
|
18
|
20 {
|
26
|
21 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(4);
|
18
|
22 UnitType unitType = equip.EquipmentForUnit;
|
19
|
23 Unit unit = GetUnit (unitType);
|
26
|
24 Assert.AreEqual(4, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
25 Assert.AreEqual(4, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
26 Assert.AreEqual(4.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
18
|
27 }
|
|
28
|
|
29 [Test()]
|
24
|
30 public void TestGetEquipmentCountsForFixedLimitItemOnDefaultSlotWithDifferentMinLimit()
|
|
31 {
|
26
|
32 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1,4);
|
24
|
33 UnitType unitType = equip.EquipmentForUnit;
|
|
34 Unit unit = GetUnit (unitType);
|
26
|
35 Assert.AreEqual(4, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
24
|
36 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
26
|
37 Assert.AreEqual(4.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
24
|
38 }
|
|
39
|
|
40 [Test()]
|
|
41 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlot()
|
18
|
42 {
|
26
|
43 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3);
|
|
44 equip.SlotName = SLOT_NAME;
|
18
|
45 UnitType unitType = equip.EquipmentForUnit;
|
26
|
46 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
|
19
|
47 Unit unit = GetUnit(unitType);
|
18
|
48 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
24
|
49 Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
26
|
50 Assert.AreEqual(2.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
51 }
|
|
52
|
|
53 [Test()]
|
|
54 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithDifferentMinLimit()
|
|
55 {
|
|
56 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3);
|
|
57 equip.SlotName = SLOT_NAME;
|
|
58 UnitType unitType = equip.EquipmentForUnit;
|
|
59 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
|
|
60 Unit unit = GetUnit(unitType);
|
|
61 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
62 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
63 Assert.AreEqual(2.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
64 }
|
|
65
|
|
66 [Test()]
|
|
67 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithMaxBelowSlotLimit()
|
|
68 {
|
|
69 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3);
|
|
70 equip.SlotName = SLOT_NAME;
|
|
71 UnitType unitType = equip.EquipmentForUnit;
|
|
72 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
|
|
73 Unit unit = GetUnit(unitType);
|
|
74 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
75 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
76 Assert.AreEqual(3.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
18
|
77 }
|
19
|
78
|
|
79 [Test()]
|
26
|
80 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithMaxBelowSlotLimitWithDifferentMinLimit()
|
|
81 {
|
|
82 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3);
|
|
83 equip.SlotName = SLOT_NAME;
|
|
84 UnitType unitType = equip.EquipmentForUnit;
|
|
85 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
|
|
86 Unit unit = GetUnit(unitType);
|
|
87 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
88 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
89 Assert.AreEqual(3.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
90 }
|
|
91
|
|
92 [Test()]
|
24
|
93 public void TestGetEquipmentCountsForFixedLimitItemOnPercentageLimitedSlot()
|
19
|
94 {
|
26
|
95 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(10);
|
|
96 equip.SlotName = SLOT_NAME;
|
19
|
97 UnitType unitType = equip.EquipmentForUnit;
|
26
|
98 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, false));
|
19
|
99 Unit unit = GetUnit(unitType);
|
26
|
100 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
101 Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
102 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
103 }
|
|
104
|
|
105 [Test()]
|
|
106 public void TestGetEquipmentCountsForFixedLimitItemOnPercentageLimitedSlotWithDifferentMinLimit()
|
|
107 {
|
|
108 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(5, 10);
|
|
109 equip.SlotName = SLOT_NAME;
|
|
110 UnitType unitType = equip.EquipmentForUnit;
|
|
111 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, false));
|
|
112 Unit unit = GetUnit(unitType);
|
|
113 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
24
|
114 Assert.AreEqual(5, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
26
|
115 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
19
|
116 }
|
|
117
|
|
118 [Test()]
|
24
|
119 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipment()
|
19
|
120 {
|
26
|
121 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3);
|
|
122 equip.SlotName = SLOT_NAME;
|
19
|
123 UnitType unitType = equip.EquipmentForUnit;
|
26
|
124 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(6));
|
19
|
125 Unit unit =GetUnit(unitType);
|
|
126 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
|
26
|
127 equip2.SlotName = SLOT_NAME;
|
19
|
128 unit.SetEquipmentAmount(equip2, 5);
|
|
129 Assert.AreEqual(1, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
24
|
130 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
26
|
131 Assert.AreEqual(1.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
132 }
|
|
133
|
|
134 [Test()]
|
|
135 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipmentDifferentMinLimit()
|
|
136 {
|
|
137 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3);
|
|
138 equip.SlotName = SLOT_NAME;
|
|
139 UnitType unitType = equip.EquipmentForUnit;
|
|
140 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(7));
|
|
141 Unit unit =GetUnit(unitType);
|
|
142 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
|
|
143 equip2.SlotName = SLOT_NAME;
|
|
144 unit.SetEquipmentAmount(equip2, 5);
|
|
145 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
146 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
147 Assert.AreEqual(2.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
19
|
148 }
|
|
149
|
|
150 [Test()]
|
24
|
151 public void TestGetEquipmentCountsForPercentageLimitItemOnDefaultSlot()
|
19
|
152 {
|
26
|
153 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
|
19
|
154 UnitType unitType = equip.EquipmentForUnit;
|
|
155 Unit unit = GetUnit(unitType);
|
26
|
156 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
157 Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
158 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
159 }
|
|
160
|
|
161 [Test()]
|
|
162 public void TestGetEquipmentCountsForPercentageLimitItemOnDefaultSlotWithDifferentMinLimit()
|
|
163 {
|
|
164 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(25, 50);
|
|
165 UnitType unitType = equip.EquipmentForUnit;
|
|
166 Unit unit = GetUnit(unitType);
|
|
167 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
168 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
169 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
19
|
170 }
|
|
171
|
|
172 [Test()]
|
24
|
173 public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlot()
|
19
|
174 {
|
26
|
175 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
|
|
176 equip.SlotName = SLOT_NAME;
|
19
|
177 UnitType unitType = equip.EquipmentForUnit;
|
26
|
178 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
|
19
|
179 Unit unit = GetUnit(unitType);
|
|
180 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
24
|
181 Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
26
|
182 Assert.AreEqual(2.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
183 }
|
|
184
|
|
185 [Test()]
|
|
186 public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithDifferentMinLimit()
|
|
187 {
|
|
188 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
|
|
189 equip.SlotName = SLOT_NAME;
|
|
190 UnitType unitType = equip.EquipmentForUnit;
|
|
191 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
|
|
192 Unit unit = GetUnit(unitType);
|
|
193 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
194 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
195 Assert.AreEqual(2.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
19
|
196 }
|
|
197
|
|
198 [Test()]
|
24
|
199 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlot()
|
19
|
200 {
|
26
|
201 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
|
|
202 equip.SlotName = SLOT_NAME;
|
|
203 UnitType unitType = equip.EquipmentForUnit;
|
|
204 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(25, false));
|
|
205 Unit unit = GetUnit(unitType);
|
|
206 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
207 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
208 Assert.AreEqual(25, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
209 }
|
|
210
|
|
211 [Test()]
|
|
212 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithDifferentMinLimit()
|
|
213 {
|
|
214 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
|
|
215 equip.SlotName = SLOT_NAME;
|
19
|
216 UnitType unitType = equip.EquipmentForUnit;
|
26
|
217 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(25, false));
|
|
218 Unit unit = GetUnit(unitType);
|
|
219 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
220 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
221 Assert.AreEqual(25, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
222 }
|
|
223
|
|
224 [Test()]
|
|
225 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithMaxBelowSlotLimit()
|
|
226 {
|
|
227 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
|
|
228 equip.SlotName = SLOT_NAME;
|
|
229 UnitType unitType = equip.EquipmentForUnit;
|
|
230 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(75, false));
|
19
|
231 Unit unit = GetUnit(unitType);
|
26
|
232 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
233 Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
234 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
235 }
|
|
236
|
|
237 [Test()]
|
|
238 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithMaxBelowSlotLimitWithDifferentMinLimit()
|
|
239 {
|
|
240 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(25, 50);
|
|
241 equip.SlotName = SLOT_NAME;
|
|
242 UnitType unitType = equip.EquipmentForUnit;
|
|
243 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(75, false));
|
|
244 Unit unit = GetUnit(unitType);
|
|
245 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
246 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
247 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
19
|
248 }
|
|
249
|
|
250 [Test()]
|
24
|
251 public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithExistingEquipment()
|
19
|
252 {
|
26
|
253 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
|
|
254 equip.SlotName = SLOT_NAME;
|
19
|
255 UnitType unitType = equip.EquipmentForUnit;
|
26
|
256 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(7));
|
|
257 Unit unit = GetUnit(unitType);
|
|
258 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
|
|
259 equip2.SlotName = SLOT_NAME;
|
|
260 unit.SetEquipmentAmount(equip2, 5);
|
|
261 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
262 Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
263 Assert.AreEqual(2.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
264 }
|
|
265
|
|
266 [Test()]
|
|
267 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipment()
|
|
268 {
|
|
269 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
|
|
270 equip.SlotName = SLOT_NAME;
|
|
271 UnitType unitType = equip.EquipmentForUnit;
|
|
272 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
|
19
|
273 Unit unit = GetUnit(unitType);
|
|
274 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
|
26
|
275 equip2.SlotName = SLOT_NAME;
|
19
|
276 unit.SetEquipmentAmount(equip2, 5);
|
26
|
277 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
|
278 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
|
279 Assert.AreEqual(3.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
|
280 }
|
|
281
|
|
282 [Test()]
|
|
283 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipmentWithDifferentMinimum()
|
|
284 {
|
|
285 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
|
|
286 equip.SlotName = SLOT_NAME;
|
|
287 UnitType unitType = equip.EquipmentForUnit;
|
|
288 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
|
|
289 Unit unit = GetUnit(unitType);
|
|
290 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
|
|
291 equip2.SlotName = SLOT_NAME;
|
|
292 unit.SetEquipmentAmount(equip2, 5);
|
|
293 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
|
21
|
294 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
|
26
|
295 Assert.AreEqual(3.0/15*100, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
|
21
|
296 }
|
22
|
297
|
|
298 [Test()]
|
|
299 public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndUnlimitedSlot()
|
|
300 {
|
23
|
301 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
|
26
|
302 equip.SlotName = SLOT_NAME;
|
22
|
303 UnitType unitType = equip.EquipmentForUnit;
|
26
|
304 unitType.AddEquipmentSlot(SLOT_NAME, new UnlimitedLimit());
|
22
|
305 Unit unit = GetUnit(unitType);
|
|
306 Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
|
|
307 }
|
|
308
|
|
309 [Test()]
|
|
310 public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndRatioSlot()
|
|
311 {
|
|
312 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
|
26
|
313 equip.SlotName = SLOT_NAME;
|
22
|
314 UnitType unitType = equip.EquipmentForUnit;
|
26
|
315 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
|
22
|
316 Unit unit = GetUnit(unitType);
|
|
317 Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
|
|
318 }
|
|
319
|
|
320 [Test()]
|
|
321 public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndAbsoluteSlot()
|
|
322 {
|
|
323 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
|
26
|
324 equip.SlotName = SLOT_NAME;
|
22
|
325 UnitType unitType = equip.EquipmentForUnit;
|
26
|
326 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
|
22
|
327 Unit unit = GetUnit(unitType);
|
|
328 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
|
|
329 }
|
23
|
330
|
|
331 [Test()]
|
|
332 public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndAbsoluteSlot()
|
|
333 {
|
24
|
334 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
|
26
|
335 equip.SlotName = SLOT_NAME;
|
23
|
336 UnitType unitType = equip.EquipmentForUnit;
|
26
|
337 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
|
23
|
338 Unit unit = GetUnit(unitType);
|
|
339 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
|
|
340 }
|
|
341
|
|
342 [Test()]
|
|
343 public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndUnlimitedSlot()
|
|
344 {
|
24
|
345 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
|
26
|
346 equip.SlotName = SLOT_NAME;
|
23
|
347 UnitType unitType = equip.EquipmentForUnit;
|
26
|
348 unitType.AddEquipmentSlot(SLOT_NAME, new UnlimitedLimit());
|
23
|
349 Unit unit = GetUnit(unitType);
|
|
350 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
|
|
351 }
|
|
352
|
|
353 [Test()]
|
|
354 public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndRatioSlot()
|
|
355 {
|
24
|
356 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
|
26
|
357 equip.SlotName = SLOT_NAME;
|
23
|
358 UnitType unitType = equip.EquipmentForUnit;
|
26
|
359 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
|
23
|
360 Unit unit = GetUnit(unitType);
|
|
361 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
|
|
362 }
|
24
|
363
|
|
364 private Unit GetUnit (UnitType unitType)
|
19
|
365 {
|
26
|
366 return new Unit ("unit", "Test Unit", 15, unitType, new MockArmyCategory (unitType.MainCategory));
|
19
|
367 }
|
18
|
368 }
|
|
369 }
|