# HG changeset patch # User IBBoard # Date 1274126653 0 # Node ID 73308371f9d8592f2a4171c4dc0d1354aae07020 # Parent 04d7cd276b1d98ead536e378fcfa1786858f5104 Re #270: Add multiple categories to API * Add tests for new property and default behaviour diff -r 04d7cd276b1d -r 73308371f9d8 API/Objects/UnitTypeTest.cs --- /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)); + } + } +} + diff -r 04d7cd276b1d -r 73308371f9d8 IBBoard.WarFoundry.API.Tests.csproj --- 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 @@ +