Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
annotate API/Util/UnitEquipmentUtilTest.cs @ 29:29e81f10bb8b
Re #208: equipmentslot limit issues
* Extend unit tests to cover extra situation
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 06 Nov 2009 20:05:29 +0000 |
parents | 0676f6a1ee9d |
children | 0cc21db8d60a |
rev | line source |
---|---|
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; | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
7 using IBBoard.CustomMath; |
18 | 8 using IBBoard.Limits; |
9 using IBBoard.WarFoundry.API.Objects; | |
10 using IBBoard.WarFoundry.API.Objects.Mock; | |
11 | |
12 namespace IBBoard.WarFoundry.API.Util | |
13 { | |
14 [TestFixture()] | |
15 public class UnitEquipmentUtilTest | |
16 { | |
26 | 17 private const string SLOT_NAME = "slot"; |
18 | |
18 | 19 [Test()] |
24 | 20 public void TestGetEquipmentCountsForFixedLimitItemOnDefaultSlot() |
18 | 21 { |
26 | 22 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(4); |
18 | 23 UnitType unitType = equip.EquipmentForUnit; |
19 | 24 Unit unit = GetUnit (unitType); |
26 | 25 Assert.AreEqual(4, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
26 Assert.AreEqual(4, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
27 Assert.AreEqual(IBBMath.Percentage(4, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
28 Assert.AreEqual(IBBMath.Percentage(4, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
18 | 29 } |
30 | |
31 [Test()] | |
24 | 32 public void TestGetEquipmentCountsForFixedLimitItemOnDefaultSlotWithDifferentMinLimit() |
33 { | |
26 | 34 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1,4); |
24 | 35 UnitType unitType = equip.EquipmentForUnit; |
36 Unit unit = GetUnit (unitType); | |
26 | 37 Assert.AreEqual(4, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
24 | 38 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
39 Assert.AreEqual(IBBMath.Percentage(4, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
40 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
24 | 41 } |
42 | |
43 [Test()] | |
44 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlot() | |
18 | 45 { |
26 | 46 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3); |
47 equip.SlotName = SLOT_NAME; | |
18 | 48 UnitType unitType = equip.EquipmentForUnit; |
26 | 49 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2)); |
19 | 50 Unit unit = GetUnit(unitType); |
18 | 51 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
24 | 52 Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
53 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
54 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 55 } |
56 | |
57 [Test()] | |
58 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithDifferentMinLimit() | |
59 { | |
60 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3); | |
61 equip.SlotName = SLOT_NAME; | |
62 UnitType unitType = equip.EquipmentForUnit; | |
63 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2)); | |
64 Unit unit = GetUnit(unitType); | |
65 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
66 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
67 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
68 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 69 } |
70 | |
71 [Test()] | |
72 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithMaxBelowSlotLimit() | |
73 { | |
74 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3); | |
75 equip.SlotName = SLOT_NAME; | |
76 UnitType unitType = equip.EquipmentForUnit; | |
77 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5)); | |
78 Unit unit = GetUnit(unitType); | |
79 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
80 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
81 Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
82 Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
18 | 83 } |
19 | 84 |
85 [Test()] | |
26 | 86 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithMaxBelowSlotLimitWithDifferentMinLimit() |
87 { | |
88 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3); | |
89 equip.SlotName = SLOT_NAME; | |
90 UnitType unitType = equip.EquipmentForUnit; | |
91 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5)); | |
92 Unit unit = GetUnit(unitType); | |
93 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
94 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
95 Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
96 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 97 } |
98 | |
99 [Test()] | |
24 | 100 public void TestGetEquipmentCountsForFixedLimitItemOnPercentageLimitedSlot() |
19 | 101 { |
26 | 102 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(10); |
103 equip.SlotName = SLOT_NAME; | |
19 | 104 UnitType unitType = equip.EquipmentForUnit; |
26 | 105 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, false)); |
19 | 106 Unit unit = GetUnit(unitType); |
26 | 107 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
108 Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
109 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); | |
27 | 110 Assert.AreEqual(50, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 111 } |
112 | |
113 [Test()] | |
114 public void TestGetEquipmentCountsForFixedLimitItemOnPercentageLimitedSlotWithDifferentMinLimit() | |
115 { | |
116 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(5, 10); | |
117 equip.SlotName = SLOT_NAME; | |
118 UnitType unitType = equip.EquipmentForUnit; | |
119 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, false)); | |
120 Unit unit = GetUnit(unitType); | |
121 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
24 | 122 Assert.AreEqual(5, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
26 | 123 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
124 Assert.AreEqual(IBBMath.Percentage(5, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
19 | 125 } |
126 | |
127 [Test()] | |
24 | 128 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipment() |
19 | 129 { |
26 | 130 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3); |
131 equip.SlotName = SLOT_NAME; | |
19 | 132 UnitType unitType = equip.EquipmentForUnit; |
26 | 133 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(6)); |
19 | 134 Unit unit =GetUnit(unitType); |
135 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType); | |
26 | 136 equip2.SlotName = SLOT_NAME; |
19 | 137 unit.SetEquipmentAmount(equip2, 5); |
138 Assert.AreEqual(1, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
24 | 139 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
140 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
141 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
142 } |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
143 |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
144 [Test()] |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
145 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipmentOfSameType() |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
146 { |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
147 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
148 equip.SlotName = SLOT_NAME; |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
149 UnitType unitType = equip.EquipmentForUnit; |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
150 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(3)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
151 Unit unit =GetUnit(unitType); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
152 unit.SetEquipmentAmount(equip, 2); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
153 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
154 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
155 Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
156 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 157 } |
158 | |
159 [Test()] | |
160 public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipmentDifferentMinLimit() | |
161 { | |
162 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3); | |
163 equip.SlotName = SLOT_NAME; | |
164 UnitType unitType = equip.EquipmentForUnit; | |
165 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(7)); | |
166 Unit unit =GetUnit(unitType); | |
167 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType); | |
168 equip2.SlotName = SLOT_NAME; | |
169 unit.SetEquipmentAmount(equip2, 5); | |
170 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
171 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
172 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
173 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
19 | 174 } |
175 | |
176 [Test()] | |
24 | 177 public void TestGetEquipmentCountsForPercentageLimitItemOnDefaultSlot() |
19 | 178 { |
26 | 179 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50); |
19 | 180 UnitType unitType = equip.EquipmentForUnit; |
181 Unit unit = GetUnit(unitType); | |
26 | 182 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
183 Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
184 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); | |
27 | 185 Assert.AreEqual(50, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 186 } |
187 | |
188 [Test()] | |
189 public void TestGetEquipmentCountsForPercentageLimitItemOnDefaultSlotWithDifferentMinLimit() | |
190 { | |
191 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(25, 50); | |
192 UnitType unitType = equip.EquipmentForUnit; | |
193 Unit unit = GetUnit(unitType); | |
194 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
195 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
196 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); | |
27 | 197 Assert.AreEqual(25, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
19 | 198 } |
199 | |
200 [Test()] | |
24 | 201 public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlot() |
19 | 202 { |
26 | 203 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50); |
204 equip.SlotName = SLOT_NAME; | |
19 | 205 UnitType unitType = equip.EquipmentForUnit; |
26 | 206 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2)); |
19 | 207 Unit unit = GetUnit(unitType); |
208 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
24 | 209 Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
210 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
26 | 211 } |
212 | |
213 [Test()] | |
214 public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithDifferentMinLimit() | |
215 { | |
216 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50); | |
217 equip.SlotName = SLOT_NAME; | |
218 UnitType unitType = equip.EquipmentForUnit; | |
219 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2)); | |
220 Unit unit = GetUnit(unitType); | |
221 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
222 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
223 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
224 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
19 | 225 } |
226 | |
227 [Test()] | |
24 | 228 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlot() |
19 | 229 { |
26 | 230 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50); |
231 equip.SlotName = SLOT_NAME; | |
232 UnitType unitType = equip.EquipmentForUnit; | |
233 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(25, false)); | |
234 Unit unit = GetUnit(unitType); | |
235 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
236 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
237 Assert.AreEqual(25, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); | |
27 | 238 Assert.AreEqual(25, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 239 } |
240 | |
241 [Test()] | |
242 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithDifferentMinLimit() | |
243 { | |
244 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50); | |
245 equip.SlotName = SLOT_NAME; | |
19 | 246 UnitType unitType = equip.EquipmentForUnit; |
26 | 247 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(25, false)); |
248 Unit unit = GetUnit(unitType); | |
249 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
250 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
251 Assert.AreEqual(25, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); | |
27 | 252 Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 253 } |
254 | |
255 [Test()] | |
256 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithMaxBelowSlotLimit() | |
257 { | |
258 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50); | |
259 equip.SlotName = SLOT_NAME; | |
260 UnitType unitType = equip.EquipmentForUnit; | |
261 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(75, false)); | |
19 | 262 Unit unit = GetUnit(unitType); |
26 | 263 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
264 Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
265 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); | |
27 | 266 Assert.AreEqual(50, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 267 } |
268 | |
269 [Test()] | |
270 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithMaxBelowSlotLimitWithDifferentMinLimit() | |
271 { | |
272 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(25, 50); | |
273 equip.SlotName = SLOT_NAME; | |
274 UnitType unitType = equip.EquipmentForUnit; | |
275 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(75, false)); | |
276 Unit unit = GetUnit(unitType); | |
277 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
278 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
279 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); | |
27 | 280 Assert.AreEqual(25, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
19 | 281 } |
282 | |
283 [Test()] | |
24 | 284 public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithExistingEquipment() |
19 | 285 { |
26 | 286 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50); |
287 equip.SlotName = SLOT_NAME; | |
19 | 288 UnitType unitType = equip.EquipmentForUnit; |
26 | 289 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(7)); |
290 Unit unit = GetUnit(unitType); | |
291 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType); | |
292 equip2.SlotName = SLOT_NAME; | |
293 unit.SetEquipmentAmount(equip2, 5); | |
294 Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
295 Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
296 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
297 Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
298 } |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
299 |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
300 [Test()] |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
301 public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithExistingEquipmentOfSameType() |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
302 { |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
303 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
304 equip.SlotName = SLOT_NAME; |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
305 UnitType unitType = equip.EquipmentForUnit; |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
306 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(10)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
307 Unit unit = GetUnit(unitType); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
308 unit.SetEquipmentAmount(equip, 5); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
309 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
310 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
311 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
312 Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 313 } |
314 | |
315 [Test()] | |
316 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipment() | |
317 { | |
318 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50); | |
319 equip.SlotName = SLOT_NAME; | |
320 UnitType unitType = equip.EquipmentForUnit; | |
321 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true)); | |
19 | 322 Unit unit = GetUnit(unitType); |
323 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType); | |
26 | 324 equip2.SlotName = SLOT_NAME; |
19 | 325 unit.SetEquipmentAmount(equip2, 5); |
26 | 326 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
327 Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); | |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
328 Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
329 Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
330 } |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
331 |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
332 [Test()] |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
333 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipmentOfSameType() |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
334 { |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
335 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
336 equip.SlotName = SLOT_NAME; |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
337 UnitType unitType = equip.EquipmentForUnit; |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
338 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
339 Unit unit = GetUnit(unitType); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
340 unit.SetEquipmentAmount(equip, 5); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
341 Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
342 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
343 Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
344 Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
26 | 345 } |
346 | |
347 [Test()] | |
348 public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipmentWithDifferentMinimum() | |
349 { | |
350 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50); | |
351 equip.SlotName = SLOT_NAME; | |
352 UnitType unitType = equip.EquipmentForUnit; | |
353 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true)); | |
354 Unit unit = GetUnit(unitType); | |
355 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType); | |
356 equip2.SlotName = SLOT_NAME; | |
357 unit.SetEquipmentAmount(equip2, 5); | |
358 Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); | |
21 | 359 Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); |
29
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
360 Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
29e81f10bb8b
Re #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents:
27
diff
changeset
|
361 Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
21 | 362 } |
22 | 363 |
364 [Test()] | |
365 public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndUnlimitedSlot() | |
366 { | |
23 | 367 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); |
26 | 368 equip.SlotName = SLOT_NAME; |
22 | 369 UnitType unitType = equip.EquipmentForUnit; |
26 | 370 unitType.AddEquipmentSlot(SLOT_NAME, new UnlimitedLimit()); |
22 | 371 Unit unit = GetUnit(unitType); |
372 Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); | |
373 } | |
374 | |
375 [Test()] | |
376 public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndRatioSlot() | |
377 { | |
378 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); | |
26 | 379 equip.SlotName = SLOT_NAME; |
22 | 380 UnitType unitType = equip.EquipmentForUnit; |
26 | 381 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true)); |
22 | 382 Unit unit = GetUnit(unitType); |
383 Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); | |
384 } | |
385 | |
386 [Test()] | |
387 public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndAbsoluteSlot() | |
388 { | |
389 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); | |
26 | 390 equip.SlotName = SLOT_NAME; |
22 | 391 UnitType unitType = equip.EquipmentForUnit; |
26 | 392 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5)); |
22 | 393 Unit unit = GetUnit(unitType); |
394 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); | |
395 } | |
23 | 396 |
397 [Test()] | |
398 public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndAbsoluteSlot() | |
399 { | |
24 | 400 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); |
26 | 401 equip.SlotName = SLOT_NAME; |
23 | 402 UnitType unitType = equip.EquipmentForUnit; |
26 | 403 unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5)); |
23 | 404 Unit unit = GetUnit(unitType); |
405 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); | |
406 } | |
407 | |
408 [Test()] | |
409 public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndUnlimitedSlot() | |
410 { | |
24 | 411 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); |
26 | 412 equip.SlotName = SLOT_NAME; |
23 | 413 UnitType unitType = equip.EquipmentForUnit; |
26 | 414 unitType.AddEquipmentSlot(SLOT_NAME, new UnlimitedLimit()); |
23 | 415 Unit unit = GetUnit(unitType); |
416 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); | |
417 } | |
418 | |
419 [Test()] | |
420 public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndRatioSlot() | |
421 { | |
24 | 422 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); |
26 | 423 equip.SlotName = SLOT_NAME; |
23 | 424 UnitType unitType = equip.EquipmentForUnit; |
26 | 425 unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true)); |
23 | 426 Unit unit = GetUnit(unitType); |
427 Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); | |
428 } | |
24 | 429 |
430 private Unit GetUnit (UnitType unitType) | |
19 | 431 { |
26 | 432 return new Unit ("unit", "Test Unit", 15, unitType, new MockArmyCategory (unitType.MainCategory)); |
19 | 433 } |
18 | 434 } |
435 } |