# HG changeset patch # User IBBoard # Date 1256677069 0 # Node ID d48e734888385f0a0fb67a1a32ed34e07b081fb4 # Parent 92db6f6a6b0b0e70ac833b9be6cfba03ad1e182d Re #198: Add equipment slots * Add additional constructors to Mock UnitEquipmentItems for more flexibility * Add test for percentage limit on numeric limited equipment diff -r 92db6f6a6b0b -r d48e73488838 API/Objects/Mock/MockNumericAmountUnitEquipmentItem.cs --- 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); } } } diff -r 92db6f6a6b0b -r d48e73488838 API/Objects/Mock/MockPercentageAmountUnitEquipmentItem.cs --- 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); } } } diff -r 92db6f6a6b0b -r d48e73488838 API/Util/UnitEquipmentUtilTest.cs --- 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));