changeset 46:73308371f9d8

Re #270: Add multiple categories to API * Add tests for new property and default behaviour
author IBBoard <dev@ibboard.co.uk>
date Mon, 17 May 2010 20:04:13 +0000
parents 04d7cd276b1d
children b4b4bde843d7
files API/Objects/UnitTypeTest.cs IBBoard.WarFoundry.API.Tests.csproj
diffstat 2 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/API/Objects/UnitTypeTest.cs	Mon May 17 20:04:13 2010 +0000
@@ -0,0 +1,34 @@
+//  This file (UnitTypeTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2010 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 IBBoard.WarFoundry.API.Objects.Mock;
+using NUnit.Framework;
+using NUnit.Framework.Constraints;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace IBBoard.WarFoundry.API.Objects
+{
+	[TestFixture()]
+	public class UnitTypeTest
+	{
+		[Test()]
+		public void TestSettingMainCategorySetsCategoriesCollection()
+		{
+			UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
+			MockCategory mockCategory = new MockCategory();
+			unitType.MainCategory = mockCategory;
+			Assert.That(unitType.Categories, Has.Member(mockCategory));
+		}
+		
+		[Test()]
+		public void TestAddingFirstCategorySetsMainCategory()
+		{
+			UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
+			MockCategory mockCategory = new MockCategory();
+			unitType.AddCategory(mockCategory);
+			Assert.That(unitType.Categories, Has.Member(mockCategory));
+			Assert.That(unitType.MainCategory, Is.EqualTo(mockCategory));
+		}
+	}
+}
+
--- a/IBBoard.WarFoundry.API.Tests.csproj	Wed May 12 19:30:06 2010 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Mon May 17 20:04:13 2010 +0000
@@ -60,6 +60,7 @@
     <Compile Include="API\FixedGameSystemWarFoundryLoader.cs" />
     <Compile Include="API\Factories\Xml\SingleXmlObjectLoader.cs" />
     <Compile Include="API\Factories\Xml\WarFoundryXmlFactoryUtilTest.cs" />
+    <Compile Include="API\Objects\UnitTypeTest.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="testdata\Test.race">