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 wrap: on
line diff
--- a/API/Objects/UnitEquipmentItemTest.cs	Tue Oct 27 20:00:54 2009 +0000
+++ b/API/Objects/UnitEquipmentItemTest.cs	Tue Oct 27 20:08:52 2009 +0000
@@ -12,147 +12,49 @@
 	[TestFixture()]
 	public class UnitEquipmentItemTest
 	{
-		/*
 		[Test()]
-		public void DefaultMinMaxNumberLimitsAreZero()
+		public void DefaultMinMaxNumberLimitsAreUnlimited()
 		{
 			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			Assert.AreEqual(0, item.MinNumber);
-			Assert.AreEqual(0, item.MaxNumber);
+			Assert.IsTrue(item.MinLimit is UnlimitedLimit);
+			Assert.IsTrue(item.MaxLimit is UnlimitedLimit);
 		}
 		
 		[Test()]
 		public void MinNumberLimitEqualsMaxLimitWhenOnlyMaxLimitSet()
 		{
 			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxNumber = 1;
-			Assert.AreEqual(1, item.MinNumber);
+			item.MaxLimit = new AbsoluteNumericLimit(1);
+			Assert.AreEqual(item.MaxLimit, item.MinLimit);
+		}
+		
+		[Test()]
+		public void MaxNumberLimitEqualsMinLimitWhenOnlyMinLimitSet()
+		{
+			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
+			item.MinLimit = new AbsoluteNumericLimit(1);
+			Assert.AreEqual(item.MinLimit, item.MaxLimit);
 		}
 		
 		[Test()]
 		public void MinNumberLimitUntouchedWhenSetFirst()
 		{
 			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinNumber = 1;
-			item.MaxNumber = 10;
-			Assert.AreEqual(1, item.MinNumber);
-		}
-		
-		[Test()]
-		public void MinNumberLimitSetToMaxWhenMaxLessThanMin()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinNumber = 10;
-			item.MaxNumber = 1;
-			Assert.AreEqual(1, item.MinNumber);
-		}
-		
-		[Test()]
-		public void MaxNumberLimitSetToMinWhenMinGreaterThanMax()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxNumber = 1;
-			item.MinNumber = 10;
-			Assert.AreEqual(10, item.MaxNumber);
+			AbsoluteNumericLimit limit = new AbsoluteNumericLimit(1);
+			item.MinLimit = limit;
+			item.MaxLimit = new AbsoluteNumericLimit(10);
+			Assert.AreEqual(limit, item.MinLimit);
 		}
 		
 		[Test()]
 		public void EqualNumberLimitsDoesntFail()
 		{
 			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxNumber = 10;
-			item.MinNumber = 10;
+			item.MaxLimit = new AbsoluteNumericLimit(10);
+			item.MinLimit = new AbsoluteNumericLimit(10);
 			item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinNumber = 10;
-			item.MaxNumber = 10;
-		}
-		
-		[Test()]
-		public void TestMinNumberLimitUnchangedWhenMaxSetToInfinity()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinNumber = 10;
-			item.MaxNumber = WarFoundryCore.INFINITY;
-			Assert.AreEqual(10, item.MinNumber);
-		}
-		
-		[Test()]
-		public void TestMaxNumberLimitSetToMinWhenMinSetToInfinity()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxNumber = 10;
-			item.MinNumber = WarFoundryCore.INFINITY;
-			Assert.AreEqual(WarFoundryCore.INFINITY, item.MaxNumber);
-		}
-		
-		[Test()]
-		public void DefaultMinMaxPercentageLimitsAreZero()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			Assert.AreEqual(0, item.MinPercentage);
-			Assert.AreEqual(0, item.MaxPercentage);
-		}
-		
-		[Test()]
-		public void MinPercentLimitEqualsMaxLimitWhenOnlyMaxLimitSet()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxPercentage = 50;
-			Assert.AreEqual(50, item.MinPercentage);
-		}
-		
-		[Test()]
-		public void MinPercentLimitUntouchedWhenSetFirst()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinPercentage = 25;
-			item.MaxPercentage = 50;
-			Assert.AreEqual(25, item.MinPercentage);
-		}
-		
-		[Test()]
-		public void MinPercentLimitSetToMaxWhenMaxLessThanMin()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinNumber = 50;
-			item.MaxPercentage = 25;
-			Assert.AreEqual(25, item.MinPercentage);
-		}
-		
-		[Test()]
-		public void MaxPercentLimitSetToMinWhenMinGreaterThanMax()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxPercentage = 25;
-			item.MinPercentage = 50;
-			Assert.AreEqual(50, item.MaxPercentage);
-		}
-		
-		[Test()]
-		public void EqualPercentLimitsDoesntFail()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxPercentage = 50;
-			item.MinPercentage = 50;
-			item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinPercentage = 50;
-			item.MaxPercentage = 50;
-		}
-		*/
-		[Test()]
-		public void TestSettingOnlyMinLimitSetsMatchingMaxLimit()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MinLimit = new UnlimitedLimit();
-			Assert.AreEqual(item.MinLimit, item.MaxLimit);
-		}
-		
-		[Test()]
-		public void TestSettingOnlyMaxLimitSetsMatchingMinLimit()
-		{
-			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
-			item.MaxLimit = new UnlimitedLimit();
-			Assert.AreEqual(item.MaxLimit, item.MinLimit);
+			item.MinLimit = new AbsoluteNumericLimit(10);
+			item.MaxLimit = new AbsoluteNumericLimit(10);
 		}
 	}
 }