changeset 49:24a40c49b6ae

Re #270: Add multiple categories to API * Add more tests of behaviour
author IBBoard <dev@ibboard.co.uk>
date Tue, 18 May 2010 19:33:27 +0000
parents ea8d30377a72
children d3519f38a0f4
files API/Objects/UnitTypeTest.cs
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/API/Objects/UnitTypeTest.cs	Tue May 18 18:49:12 2010 +0000
+++ b/API/Objects/UnitTypeTest.cs	Tue May 18 19:33:27 2010 +0000
@@ -26,7 +26,22 @@
 			UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
 			MockCategory mockCategory = new MockCategory();
 			unitType.AddCategory(mockCategory);
+			Assert.That(unitType.Categories.Length, Is.EqualTo(1));
 			Assert.That(unitType.Categories, Has.Member(mockCategory));
+			Assert.That(unitType.MainCategory, Is.EqualTo(mockCategory));			
+		}
+
+		[Test()]
+		public void TestAddingMultipleCategoriesSetsMainCategory()
+		{
+			UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
+			MockCategory mockCategory = new MockCategory();
+			unitType.AddCategory(mockCategory);
+			Category mockCategory2 = new Category("id1", "CatName");
+			unitType.AddCategory(mockCategory2);
+			Assert.That(unitType.Categories.Length, Is.EqualTo(2));
+			Assert.That(unitType.Categories, Has.Member(mockCategory));
+			Assert.That(unitType.Categories, Has.Member(mockCategory2));
 			Assert.That(unitType.MainCategory, Is.EqualTo(mockCategory));
 		}
 	}