changeset 20:beaf7a48a93f

Re #198: Create equipment slots * Fix UnitEquipmentItem tests for new limits
author IBBoard <dev@ibboard.co.uk>
date Tue, 27 Oct 2009 20:08:52 +0000
parents 9b23e72ba3cf
children 40a2fd337907
files API/Objects/UnitEquipmentItemTest.cs
diffstat 1 files changed, 21 insertions(+), 119 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/UnitEquipmentItemTest.cs	Tue Oct 27 20:00:54 2009 +0000
     1.2 +++ b/API/Objects/UnitEquipmentItemTest.cs	Tue Oct 27 20:08:52 2009 +0000
     1.3 @@ -12,147 +12,49 @@
     1.4  	[TestFixture()]
     1.5  	public class UnitEquipmentItemTest
     1.6  	{
     1.7 -		/*
     1.8  		[Test()]
     1.9 -		public void DefaultMinMaxNumberLimitsAreZero()
    1.10 +		public void DefaultMinMaxNumberLimitsAreUnlimited()
    1.11  		{
    1.12  			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.13 -			Assert.AreEqual(0, item.MinNumber);
    1.14 -			Assert.AreEqual(0, item.MaxNumber);
    1.15 +			Assert.IsTrue(item.MinLimit is UnlimitedLimit);
    1.16 +			Assert.IsTrue(item.MaxLimit is UnlimitedLimit);
    1.17  		}
    1.18  		
    1.19  		[Test()]
    1.20  		public void MinNumberLimitEqualsMaxLimitWhenOnlyMaxLimitSet()
    1.21  		{
    1.22  			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.23 -			item.MaxNumber = 1;
    1.24 -			Assert.AreEqual(1, item.MinNumber);
    1.25 +			item.MaxLimit = new AbsoluteNumericLimit(1);
    1.26 +			Assert.AreEqual(item.MaxLimit, item.MinLimit);
    1.27 +		}
    1.28 +		
    1.29 +		[Test()]
    1.30 +		public void MaxNumberLimitEqualsMinLimitWhenOnlyMinLimitSet()
    1.31 +		{
    1.32 +			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.33 +			item.MinLimit = new AbsoluteNumericLimit(1);
    1.34 +			Assert.AreEqual(item.MinLimit, item.MaxLimit);
    1.35  		}
    1.36  		
    1.37  		[Test()]
    1.38  		public void MinNumberLimitUntouchedWhenSetFirst()
    1.39  		{
    1.40  			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.41 -			item.MinNumber = 1;
    1.42 -			item.MaxNumber = 10;
    1.43 -			Assert.AreEqual(1, item.MinNumber);
    1.44 -		}
    1.45 -		
    1.46 -		[Test()]
    1.47 -		public void MinNumberLimitSetToMaxWhenMaxLessThanMin()
    1.48 -		{
    1.49 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.50 -			item.MinNumber = 10;
    1.51 -			item.MaxNumber = 1;
    1.52 -			Assert.AreEqual(1, item.MinNumber);
    1.53 -		}
    1.54 -		
    1.55 -		[Test()]
    1.56 -		public void MaxNumberLimitSetToMinWhenMinGreaterThanMax()
    1.57 -		{
    1.58 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.59 -			item.MaxNumber = 1;
    1.60 -			item.MinNumber = 10;
    1.61 -			Assert.AreEqual(10, item.MaxNumber);
    1.62 +			AbsoluteNumericLimit limit = new AbsoluteNumericLimit(1);
    1.63 +			item.MinLimit = limit;
    1.64 +			item.MaxLimit = new AbsoluteNumericLimit(10);
    1.65 +			Assert.AreEqual(limit, item.MinLimit);
    1.66  		}
    1.67  		
    1.68  		[Test()]
    1.69  		public void EqualNumberLimitsDoesntFail()
    1.70  		{
    1.71  			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.72 -			item.MaxNumber = 10;
    1.73 -			item.MinNumber = 10;
    1.74 +			item.MaxLimit = new AbsoluteNumericLimit(10);
    1.75 +			item.MinLimit = new AbsoluteNumericLimit(10);
    1.76  			item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.77 -			item.MinNumber = 10;
    1.78 -			item.MaxNumber = 10;
    1.79 -		}
    1.80 -		
    1.81 -		[Test()]
    1.82 -		public void TestMinNumberLimitUnchangedWhenMaxSetToInfinity()
    1.83 -		{
    1.84 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.85 -			item.MinNumber = 10;
    1.86 -			item.MaxNumber = WarFoundryCore.INFINITY;
    1.87 -			Assert.AreEqual(10, item.MinNumber);
    1.88 -		}
    1.89 -		
    1.90 -		[Test()]
    1.91 -		public void TestMaxNumberLimitSetToMinWhenMinSetToInfinity()
    1.92 -		{
    1.93 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
    1.94 -			item.MaxNumber = 10;
    1.95 -			item.MinNumber = WarFoundryCore.INFINITY;
    1.96 -			Assert.AreEqual(WarFoundryCore.INFINITY, item.MaxNumber);
    1.97 -		}
    1.98 -		
    1.99 -		[Test()]
   1.100 -		public void DefaultMinMaxPercentageLimitsAreZero()
   1.101 -		{
   1.102 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.103 -			Assert.AreEqual(0, item.MinPercentage);
   1.104 -			Assert.AreEqual(0, item.MaxPercentage);
   1.105 -		}
   1.106 -		
   1.107 -		[Test()]
   1.108 -		public void MinPercentLimitEqualsMaxLimitWhenOnlyMaxLimitSet()
   1.109 -		{
   1.110 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.111 -			item.MaxPercentage = 50;
   1.112 -			Assert.AreEqual(50, item.MinPercentage);
   1.113 -		}
   1.114 -		
   1.115 -		[Test()]
   1.116 -		public void MinPercentLimitUntouchedWhenSetFirst()
   1.117 -		{
   1.118 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.119 -			item.MinPercentage = 25;
   1.120 -			item.MaxPercentage = 50;
   1.121 -			Assert.AreEqual(25, item.MinPercentage);
   1.122 -		}
   1.123 -		
   1.124 -		[Test()]
   1.125 -		public void MinPercentLimitSetToMaxWhenMaxLessThanMin()
   1.126 -		{
   1.127 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.128 -			item.MinNumber = 50;
   1.129 -			item.MaxPercentage = 25;
   1.130 -			Assert.AreEqual(25, item.MinPercentage);
   1.131 -		}
   1.132 -		
   1.133 -		[Test()]
   1.134 -		public void MaxPercentLimitSetToMinWhenMinGreaterThanMax()
   1.135 -		{
   1.136 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.137 -			item.MaxPercentage = 25;
   1.138 -			item.MinPercentage = 50;
   1.139 -			Assert.AreEqual(50, item.MaxPercentage);
   1.140 -		}
   1.141 -		
   1.142 -		[Test()]
   1.143 -		public void EqualPercentLimitsDoesntFail()
   1.144 -		{
   1.145 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.146 -			item.MaxPercentage = 50;
   1.147 -			item.MinPercentage = 50;
   1.148 -			item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.149 -			item.MinPercentage = 50;
   1.150 -			item.MaxPercentage = 50;
   1.151 -		}
   1.152 -		*/
   1.153 -		[Test()]
   1.154 -		public void TestSettingOnlyMinLimitSetsMatchingMaxLimit()
   1.155 -		{
   1.156 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.157 -			item.MinLimit = new UnlimitedLimit();
   1.158 -			Assert.AreEqual(item.MinLimit, item.MaxLimit);
   1.159 -		}
   1.160 -		
   1.161 -		[Test()]
   1.162 -		public void TestSettingOnlyMaxLimitSetsMatchingMinLimit()
   1.163 -		{
   1.164 -			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
   1.165 -			item.MaxLimit = new UnlimitedLimit();
   1.166 -			Assert.AreEqual(item.MaxLimit, item.MinLimit);
   1.167 +			item.MinLimit = new AbsoluteNumericLimit(10);
   1.168 +			item.MaxLimit = new AbsoluteNumericLimit(10);
   1.169  		}
   1.170  	}
   1.171  }