Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 25:d48e73488838
Re #198: Add equipment slots
* Add additional constructors to Mock UnitEquipmentItems for more flexibility
* Add test for percentage limit on numeric limited equipment
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 27 Oct 2009 20:57:49 +0000 |
parents | 92db6f6a6b0b |
children | e6bf9b5e1b94 |
files | API/Objects/Mock/MockNumericAmountUnitEquipmentItem.cs API/Objects/Mock/MockPercentageAmountUnitEquipmentItem.cs API/Util/UnitEquipmentUtilTest.cs |
diffstat | 3 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Objects/Mock/MockNumericAmountUnitEquipmentItem.cs Tue Oct 27 20:52:56 2009 +0000 +++ b/API/Objects/Mock/MockNumericAmountUnitEquipmentItem.cs Tue Oct 27 20:57:49 2009 +0000 @@ -15,9 +15,14 @@ } - public MockNumericAmountUnitEquipmentItem (int limit) : base(new MockEquipmentItem(), new MockUnitType()) + public MockNumericAmountUnitEquipmentItem (int limit) : this(limit, limit) { - MaxLimit = new NumericSizeConstrainedLimit(limit); + } + + public MockNumericAmountUnitEquipmentItem(int min, int max) : base(new MockEquipmentItem(), new MockUnitType()) + { + MinLimit = new NumericSizeConstrainedLimit(min); + MaxLimit = new NumericSizeConstrainedLimit(max); } } }
--- a/API/Objects/Mock/MockPercentageAmountUnitEquipmentItem.cs Tue Oct 27 20:52:56 2009 +0000 +++ b/API/Objects/Mock/MockPercentageAmountUnitEquipmentItem.cs Tue Oct 27 20:57:49 2009 +0000 @@ -14,9 +14,17 @@ { } - public MockPercentageAmountUnitEquipmentItem(EquipmentItem item, UnitType type) : base(item, type) + public MockPercentageAmountUnitEquipmentItem(double percentage) : this(new MockEquipmentItem(), new MockUnitType(), percentage) + { + } + + public MockPercentageAmountUnitEquipmentItem(EquipmentItem item, UnitType type) : this(item, type, 50) { - MaxLimit = new SimpleRoundedPercentageLimit(50, false); + } + + public MockPercentageAmountUnitEquipmentItem(EquipmentItem item, UnitType type, double percentage) : base(item, type) + { + MaxLimit = new SimpleRoundedPercentageLimit(percentage, false); } } }
--- a/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:52:56 2009 +0000 +++ b/API/Util/UnitEquipmentUtilTest.cs Tue Oct 27 20:57:49 2009 +0000 @@ -199,6 +199,15 @@ Assert.AreEqual(75, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); } + [Test()] + public void TestGetMaxPercentageForNumericLimitedEquipmentOnUnlimitedSlot() + { + UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(5); + UnitType unitType = equip.EquipmentForUnit; + Unit unit = GetUnit(unitType); + Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); + } + private Unit GetUnit (UnitType unitType) { return new Unit ("unit", "Test Unit", 10, unitType, new MockArmyCategory (unitType.MainCategory));