Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 23:54abb61b9db8
Re #198: Add equipment slots
* Complete unit tests for new method
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 27 Oct 2009 20:30:12 +0000 |
parents | 25b21f564348 |
children | 92db6f6a6b0b |
files | API/Util/UnitEquipmentUtilTest.cs |
diffstat | 1 files changed, 39 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:27:02 2009 +0000 +++ b/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:30:12 2009 +0000 @@ -203,9 +203,11 @@ [Test()] public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndUnlimitedSlot() { - UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; equip.MinLimit = new SimpleRoundedPercentageLimit(50, true); UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new UnlimitedLimit()); Unit unit = GetUnit(unitType); Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); } @@ -233,6 +235,42 @@ Unit unit = GetUnit(unitType); Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); } + + [Test()] + public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndAbsoluteSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + equip.MinLimit = new AbsoluteNumericLimit(50); + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(5)); + Unit unit = GetUnit(unitType); + Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); + } + + [Test()] + public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndUnlimitedSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + equip.MinLimit = new AbsoluteNumericLimit(50); + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new UnlimitedLimit()); + Unit unit = GetUnit(unitType); + Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); + } + + [Test()] + public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndRatioSlot() + { + UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(); + equip.SlotName = "slot"; + equip.MinLimit = new AbsoluteNumericLimit(50); + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new SimpleRoundedPercentageLimit(50, true)); + Unit unit = GetUnit(unitType); + Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip)); + } private static Unit GetUnit (UnitType unitType) {