annotate API/Objects/UnitTest.cs @ 17:4480d7151d35

Re #198: Add equipment slots * Add tests for removing items
author IBBoard <dev@ibboard.co.uk>
date Sat, 24 Oct 2009 14:04:43 +0000
parents 74346d5c17fe
children 9b23e72ba3cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
19fc7a733064 Re #198: Add slots with counts to units
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.
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using NUnit.Framework;
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Objects.Mock;
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 [TestFixture()]
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public class UnitTest
15
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
13 {
14
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [Test()]
15
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
15 public void TestAddNumericAmountEquipmentAddsEquipmentSelection()
14
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
15
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
17 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
14
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 UnitType unitType = equip.EquipmentForUnit;
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 Unit unit = new Unit(unitType, new MockArmyCategory(unitType.MainCategory));
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 unit.SetEquipmentAmount(equip, WarFoundryCore.INFINITY);
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 Assert.AreEqual(WarFoundryCore.INFINITY, unit.GetEquipmentAmount(equip));
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 Assert.IsFalse(unit.GetEquipmentAmountIsRatio(equip));
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 }
15
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
24
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
25 [Test()]
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
26 public void TestRemoveNumericAmountEquipmentRemovesEquipmentSelection()
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
27 {
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
28 UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
29 UnitType unitType = equip.EquipmentForUnit;
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
30 Unit unit = new Unit(unitType, new MockArmyCategory(unitType.MainCategory));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
31 unit.SetEquipmentAmount(equip, WarFoundryCore.INFINITY);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
32 unit.SetEquipmentAmount(equip, 0);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
33 Assert.AreEqual(0, unit.GetEquipmentAmount(equip));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
34 }
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
35
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
36 [Test()]
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
37 public void TestAddPercentageAmountEquipmentAddsEquipmentSelection()
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
38 {
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
39 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
40 UnitType unitType = equip.EquipmentForUnit;
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
41 Unit unit = new Unit(unitType, new MockArmyCategory(unitType.MainCategory));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
42 unit.SetEquipmentRatio(equip, 50);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
43 Assert.AreEqual(50, unit.GetEquipmentAmount(equip));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
44 Assert.IsTrue(unit.GetEquipmentAmountIsRatio(equip));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
45 }
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
46
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
47 [Test()]
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
48 public void TestRemovePercentageAmountEquipmentRemovesEquipmentSelection()
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
49 {
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
50 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
51 UnitType unitType = equip.EquipmentForUnit;
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
52 Unit unit = new Unit(unitType, new MockArmyCategory(unitType.MainCategory));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
53 unit.SetEquipmentRatio(equip, 50);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
54 unit.SetEquipmentRatio(equip, 0);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
55 Assert.AreEqual(0, unit.GetEquipmentAmount(equip));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
56 }
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
57
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
58 [Test()]
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
59 public void TestAddNumericAmountOfPercentageAmountEquipmentAddsEquipmentSelection()
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
60 {
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
61 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
62 UnitType unitType = equip.EquipmentForUnit;
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
63 Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
64 unit.Size = 5;
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
65 unit.SetEquipmentAmount(equip, 2);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
66 Assert.AreEqual(2, unit.GetEquipmentAmount(equip));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
67 Assert.IsFalse(unit.GetEquipmentAmountIsRatio(equip));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
68 }
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
69
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
70 [Test()]
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
71 public void TestRemoveNumericAmountOfPercentageAmountEquipmentRemovesEquipmentSelection()
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
72 {
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
73 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
74 UnitType unitType = equip.EquipmentForUnit;
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
75 Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
76 unit.Size = 5;
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
77 unit.SetEquipmentAmount(equip, 2);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
78 unit.SetEquipmentAmount(equip, 0);
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
79 Assert.AreEqual(0, unit.GetEquipmentAmount(equip));
1119b6f48e8e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
80 }
16
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
81
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
82 [Test()]
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
83 public void TestAmountInSlotWithNoItems()
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
84 {
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
85 UnitType unitType = new MockUnitType();
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
86 Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
87 Assert.AreEqual(0, unit.GetEquipmentAmountInSlot(""));
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
88 }
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
89
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
90 [Test()]
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
91 public void TestAmountInSlotWithOneItem()
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
92 {
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
93 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
94 string slotName = "TestSlot";
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
95 equip.SlotName = slotName;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
96 UnitType unitType = equip.EquipmentForUnit;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
97 Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
98 unit.Size = 5;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
99 unit.SetEquipmentRatio(equip, 50);
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
100 Assert.AreEqual(2, unit.GetEquipmentAmountInSlot(slotName));
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
101 }
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
102
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
103 [Test()]
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
104 public void TestAmountInSlotWithMultipleItems()
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
105 {
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
106 UnitEquipmentItem equip1 = new MockPercentageAmountUnitEquipmentItem();
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
107 string slotName = "TestSlot";
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
108 equip1.SlotName = slotName;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
109 UnitType unitType = equip1.EquipmentForUnit;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
110 Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
111 unit.Size = 10;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
112 unit.SetEquipmentRatio(equip1, 50);
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
113 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
114 equip2.SlotName = slotName;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
115 equip2.MinPercentage = 0;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
116 UnitEquipmentItem equip3 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip3"), unitType);
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
117 equip3.SlotName = slotName;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
118 equip3.MinPercentage = 0;
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
119 unit.SetEquipmentRatio(equip2, 25);
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
120 unit.SetEquipmentRatio(equip3, 10);
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
121 Assert.AreEqual(8, unit.GetEquipmentAmountInSlot(slotName));
74346d5c17fe Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
122 }
17
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
123
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
124 [Test()]
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
125 public void TestAmountInSlotWithOneItemAfterRemove()
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
126 {
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
127 UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
128 string slotName = "TestSlot";
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
129 equip.SlotName = slotName;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
130 UnitType unitType = equip.EquipmentForUnit;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
131 Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
132 unit.Size = 5;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
133 unit.SetEquipmentRatio(equip, 50);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
134 unit.SetEquipmentRatio(equip, 0);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
135 Assert.AreEqual(0, unit.GetEquipmentAmountInSlot(slotName));
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
136 }
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
137
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
138 [Test()]
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
139 public void TestAmountInSlotWithMultipleItemsAfterRemove()
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
140 {
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
141 UnitEquipmentItem equip1 = new MockPercentageAmountUnitEquipmentItem();
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
142 string slotName = "TestSlot";
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
143 equip1.SlotName = slotName;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
144 UnitType unitType = equip1.EquipmentForUnit;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
145 Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
146 unit.Size = 10;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
147 unit.SetEquipmentRatio(equip1, 50);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
148 UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
149 equip2.SlotName = slotName;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
150 equip2.MinPercentage = 0;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
151 UnitEquipmentItem equip3 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip3"), unitType);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
152 equip3.SlotName = slotName;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
153 equip3.MinPercentage = 0;
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
154 unit.SetEquipmentRatio(equip2, 25);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
155 unit.SetEquipmentRatio(equip3, 10);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
156 unit.SetEquipmentAmount(equip1, 0);
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
157 Assert.AreEqual(3, unit.GetEquipmentAmountInSlot(slotName));
4480d7151d35 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
158 }
14
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 }
19fc7a733064 Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 }