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 diff
     1.1 --- a/API/Objects/Mock/MockNumericAmountUnitEquipmentItem.cs	Tue Oct 27 20:52:56 2009 +0000
     1.2 +++ b/API/Objects/Mock/MockNumericAmountUnitEquipmentItem.cs	Tue Oct 27 20:57:49 2009 +0000
     1.3 @@ -15,9 +15,14 @@
     1.4  		}
     1.5  			
     1.6  
     1.7 -		public MockNumericAmountUnitEquipmentItem (int limit) : base(new MockEquipmentItem(), new MockUnitType())
     1.8 +		public MockNumericAmountUnitEquipmentItem (int limit) : this(limit, limit)
     1.9  		{
    1.10 -			MaxLimit = new NumericSizeConstrainedLimit(limit);
    1.11 +		}
    1.12 +		
    1.13 +		public MockNumericAmountUnitEquipmentItem(int min, int max) : base(new MockEquipmentItem(), new MockUnitType())
    1.14 +		{
    1.15 +			MinLimit = new NumericSizeConstrainedLimit(min);
    1.16 +			MaxLimit = new NumericSizeConstrainedLimit(max);
    1.17  		}
    1.18  	}
    1.19  }
     2.1 --- a/API/Objects/Mock/MockPercentageAmountUnitEquipmentItem.cs	Tue Oct 27 20:52:56 2009 +0000
     2.2 +++ b/API/Objects/Mock/MockPercentageAmountUnitEquipmentItem.cs	Tue Oct 27 20:57:49 2009 +0000
     2.3 @@ -14,9 +14,17 @@
     2.4  		{
     2.5  		}
     2.6  		
     2.7 -		public MockPercentageAmountUnitEquipmentItem(EquipmentItem item, UnitType type) : base(item, type)
     2.8 +		public MockPercentageAmountUnitEquipmentItem(double percentage) : this(new MockEquipmentItem(), new MockUnitType(), percentage)
     2.9  		{
    2.10 -			MaxLimit = new SimpleRoundedPercentageLimit(50, false);
    2.11 +		}
    2.12 +		
    2.13 +		public MockPercentageAmountUnitEquipmentItem(EquipmentItem item, UnitType type) : this(item, type, 50)
    2.14 +		{
    2.15 +		}
    2.16 +		
    2.17 +		public MockPercentageAmountUnitEquipmentItem(EquipmentItem item, UnitType type, double percentage) : base(item, type)
    2.18 +		{
    2.19 +			MaxLimit = new SimpleRoundedPercentageLimit(percentage, false);
    2.20  		}
    2.21  	}
    2.22  }
     3.1 --- a/API/Util/UnitEquipmentUtilTest.cs	Tue Oct 27 20:52:56 2009 +0000
     3.2 +++ b/API/Util/UnitEquipmentUtilTest.cs	Tue Oct 27 20:57:49 2009 +0000
     3.3 @@ -199,6 +199,15 @@
     3.4  			Assert.AreEqual(75, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
     3.5  		}
     3.6  		
     3.7 +		[Test()]
     3.8 +		public void TestGetMaxPercentageForNumericLimitedEquipmentOnUnlimitedSlot()
     3.9 +		{
    3.10 +			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(5);
    3.11 +			UnitType unitType = equip.EquipmentForUnit;
    3.12 +			Unit unit = GetUnit(unitType);
    3.13 +			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
    3.14 +		}
    3.15 +		
    3.16  		private Unit GetUnit (UnitType unitType)
    3.17  		{
    3.18  			return new Unit ("unit", "Test Unit", 10, unitType, new MockArmyCategory (unitType.MainCategory));