annotate API/Util/UnitEquipmentUtilTest.cs @ 32:9bf542b76de2

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