changeset 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 e8e7554fb7f3
files API/Objects/UnitTest.cs
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/API/Objects/UnitTest.cs	Sat Oct 24 14:02:50 2009 +0000
+++ b/API/Objects/UnitTest.cs	Sat Oct 24 14:04:43 2009 +0000
@@ -120,5 +120,41 @@
 			unit.SetEquipmentRatio(equip3, 10);
 			Assert.AreEqual(8, unit.GetEquipmentAmountInSlot(slotName));
 		}
+		
+		[Test()]
+		public void TestAmountInSlotWithOneItemAfterRemove()
+		{
+			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
+			string slotName = "TestSlot";
+			equip.SlotName = slotName;
+			UnitType unitType = equip.EquipmentForUnit;
+			Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
+			unit.Size = 5;
+			unit.SetEquipmentRatio(equip, 50);
+			unit.SetEquipmentRatio(equip, 0);
+			Assert.AreEqual(0, unit.GetEquipmentAmountInSlot(slotName));
+		}
+		
+		[Test()]
+		public void TestAmountInSlotWithMultipleItemsAfterRemove()
+		{
+			UnitEquipmentItem equip1 = new MockPercentageAmountUnitEquipmentItem();
+			string slotName = "TestSlot";
+			equip1.SlotName = slotName;
+			UnitType unitType = equip1.EquipmentForUnit;
+			Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
+			unit.Size = 10;
+			unit.SetEquipmentRatio(equip1, 50);
+			UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
+			equip2.SlotName = slotName;
+			equip2.MinPercentage = 0;
+			UnitEquipmentItem equip3 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip3"), unitType);
+			equip3.SlotName = slotName;
+			equip3.MinPercentage = 0;
+			unit.SetEquipmentRatio(equip2, 25);
+			unit.SetEquipmentRatio(equip3, 10);
+			unit.SetEquipmentAmount(equip1, 0);
+			Assert.AreEqual(3, unit.GetEquipmentAmountInSlot(slotName));
+		}
 	}
 }