Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 21:40a2fd337907
Re #198: Add equipment slots
* Add tests for min amount
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 27 Oct 2009 20:18:22 +0000 |
parents | beaf7a48a93f |
children | 25b21f564348 |
files | API/Util/UnitEquipmentUtilTest.cs |
diffstat | 1 files changed, 94 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:08:52 2009 +0000 +++ b/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:18:22 2009 +0000 @@ -21,7 +21,6 @@ Unit unit = GetUnit (unitType); Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); } - [Test()] public void TestGetMaxEquipmentCountForFixedLimitItemOnNumberLimitedSlot() @@ -106,6 +105,100 @@ unit.SetEquipmentAmount(equip2, 5); Assert.AreEqual(1, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); } + + + [Test()] + public void TestGetMinEquipmentCountForFixedLimitItemOnDefaultSlot() + { + UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3); + UnitType unitType = equip.EquipmentForUnit; + Unit unit = GetUnit (unitType); + Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMinEquipmentCountForFixedLimitItemOnNumberLimitedSlot() + { + UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); + equip.MinLimit = new NumericSizeConstrainedLimit(3); + equip.SlotName = "slot"; + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(2)); + Unit unit = GetUnit(unitType); + Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMinEquipmentCountForFixedLimitItemOnPercentageLimitedSlot() + { + UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); + equip.MinLimit = new NumericSizeConstrainedLimit(7); + equip.SlotName = "slot"; + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new SimpleRoundedPercentageLimit(50, false)); + Unit unit = GetUnit(unitType); + Assert.AreEqual(5, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMinEquipmentCountForFixedLimitItemOnNumberLimitedSlotWithExistingEquipment() + { + UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); + equip.MinLimit = new NumericSizeConstrainedLimit(3); + equip.SlotName = "slot"; + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(6)); + Unit unit =GetUnit(unitType); + UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType); + equip2.SlotName = "slot"; + unit.SetEquipmentAmount(equip2, 5); + Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMinEquipmentCountForPercentageLimitItemOnDefaultSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + UnitType unitType = equip.EquipmentForUnit; + Unit unit = GetUnit(unitType); + Assert.AreEqual(5, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMinEquipmentCountForPercentageLimitItemOnNumberLimitedSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(2)); + Unit unit = GetUnit(unitType); + Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMinEquipmentCountForPercentageLimitItemOnPercentageLimitedSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new SimpleRoundedPercentageLimit(25, false)); + Unit unit = GetUnit(unitType); + Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMinEquipmentCountForPercentageLimitItemOnNumberLimitedSlotWithExistingEquipment() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(6)); + Unit unit = GetUnit(unitType); + UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType); + equip2.SlotName = "slot"; + unit.SetEquipmentAmount(equip2, 5); + Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); + } private static Unit GetUnit (UnitType unitType) {