Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 22:25b21f564348
Re #198: Add equipment slot
* Add initial unit tests for new "is equipment and slot ratio limited" method
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 27 Oct 2009 20:27:02 +0000 |
parents | 40a2fd337907 |
children | 54abb61b9db8 |
files | API/Util/UnitEquipmentUtilTest.cs |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:18:22 2009 +0000 +++ b/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:27:02 2009 +0000 @@ -199,6 +199,40 @@ unit.SetEquipmentAmount(equip2, 5); Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip)); } + + [Test()] + public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndUnlimitedSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.MinLimit = new SimpleRoundedPercentageLimit(50, true); + UnitType unitType = equip.EquipmentForUnit; + Unit unit = GetUnit(unitType); + Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); + } + + [Test()] + public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndRatioSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + equip.MinLimit = new SimpleRoundedPercentageLimit(50, true); + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new SimpleRoundedPercentageLimit(50, true)); + Unit unit = GetUnit(unitType); + Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); + } + + [Test()] + public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndAbsoluteSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + equip.MinLimit = new SimpleRoundedPercentageLimit(50, true); + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(5)); + Unit unit = GetUnit(unitType); + Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); + } private static Unit GetUnit (UnitType unitType) {