view API/Objects/UnitTypeTest.cs @ 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 73308371f9d8
children a3bc8174299f
line wrap: on
line source

//  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.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));
		}
	}
}