changeset 18:e8e7554fb7f3

Re #198: Add slots with count * Add initial unit equipment util tests
author IBBoard <dev@ibboard.co.uk>
date Sat, 24 Oct 2009 18:59:30 +0000
parents 4480d7151d35
children 9b23e72ba3cf
files API/Util/UnitEquipmentUtilTest.cs IBBoard.WarFoundry.API.Tests.csproj
diffstat 2 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/API/Util/UnitEquipmentUtilTest.cs	Sat Oct 24 18:59:30 2009 +0000
@@ -0,0 +1,37 @@
+// This file (UnitEquipmentItemUtilTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard
+// 
+// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
+
+using System;
+using NUnit.Framework;
+using IBBoard.Limits;
+using IBBoard.WarFoundry.API.Objects;
+using IBBoard.WarFoundry.API.Objects.Mock;
+
+namespace IBBoard.WarFoundry.API.Util
+{
+	[TestFixture()]
+	public class UnitEquipmentUtilTest
+	{
+		[Test()]
+		public void TestGetMaxEquipmentCountForFixedLimitItemOnDefaultSlot()
+		{
+			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
+			equip.MaxNumber = 3;
+			UnitType unitType = equip.EquipmentForUnit;
+			Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
+			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
+		}
+		
+		[Test()]
+		public void TestGetMaxEquipmentCountForFixedLimitItemOnNumberLimitedSlot()
+		{
+			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
+			equip.MaxNumber = 3;
+			UnitType unitType = equip.EquipmentForUnit;
+			unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(2));
+			Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory));
+			Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
+		}
+	}
+}
--- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Oct 24 14:04:43 2009 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Sat Oct 24 18:59:30 2009 +0000
@@ -56,6 +56,7 @@
     <Compile Include="API\Objects\Mock\MockNumericAmountUnitEquipmentItem.cs" />
     <Compile Include="API\Objects\Mock\MockPercentageAmountUnitEquipmentItem.cs" />
     <Compile Include="API\Objects\Mock\MockUnit.cs" />
+    <Compile Include="API\Util\UnitEquipmentUtilTest.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="testdata\Test.race">
@@ -78,6 +79,10 @@
       <Project>{951E6C7A-7FBA-4F68-9D9E-F48618BB9626}</Project>
       <Name>IBBoard.WarFoundry.API</Name>
     </ProjectReference>
+    <ProjectReference Include="..\IBBoard\IBBoard.csproj">
+      <Project>{5DFD64F6-FC2B-4B4F-B92E-483BAC468105}</Project>
+      <Name>IBBoard</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="API\" />
@@ -85,6 +90,7 @@
     <Folder Include="API\Objects\Mock\" />
     <Folder Include="API\Factories\" />
     <Folder Include="API\Factories\Mock\" />
+    <Folder Include="API\Util\" />
   </ItemGroup>
   <ProjectExtensions>
     <MonoDevelop>