Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
view API/Objects/UnitTypeTest.cs @ 128:7ca536ccd27a
Re #27:
* Start testing adding requirements to unit types
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 09 Apr 2011 15:59:55 +0000 |
parents | a3bc8174299f |
children | d28c3c1ec1ec |
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; using IBBoard.WarFoundry.API.Objects.Requirement; namespace IBBoard.WarFoundry.API.Objects { [TestFixture()] public class UnitTypeTest { [Test()] public void TestSettingMainCategorySetsCategoriesCollection() { UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace()); MockCategory mockCategory = MockCategory.GetCategory(); unitType.MainCategory = mockCategory; Assert.That(unitType.Categories, Has.Member(mockCategory)); } [Test()] public void TestAddingFirstCategorySetsMainCategory() { UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace()); MockCategory mockCategory = MockCategory.GetCategory(); 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 = MockCategory.GetCategory(); 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)); } [Test] public void TestAddingRequirementsToUnitType() { UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace()); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType); Assert.That(unitType.GetRequirements(), Has.Length(0)); unitType.AddRequirement(req); Assert.That(unitType.GetRequirements(), Has.Length(1)); } } }