annotate API/Objects/UnitTypeTest.cs @ 61:27625216d8d6

Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Add test for ability loading and validation when the ability exists * Move old test data for non-existant ability into sub-folder
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 Jun 2010 19:09:07 +0000
parents 24a40c49b6ae
children a3bc8174299f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitTypeTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2010 IBBoard
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // // 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.
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using IBBoard.WarFoundry.API.Objects.Mock;
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using NUnit.Framework.Constraints;
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 [TestFixture()]
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public class UnitTypeTest
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [Test()]
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 public void TestSettingMainCategorySetsCategoriesCollection()
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 MockCategory mockCategory = new MockCategory();
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 unitType.MainCategory = mockCategory;
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 Assert.That(unitType.Categories, Has.Member(mockCategory));
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 }
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 [Test()]
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 public void TestAddingFirstCategorySetsMainCategory()
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 {
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 MockCategory mockCategory = new MockCategory();
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 unitType.AddCategory(mockCategory);
49
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
29 Assert.That(unitType.Categories.Length, Is.EqualTo(1));
46
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 Assert.That(unitType.Categories, Has.Member(mockCategory));
49
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
31 Assert.That(unitType.MainCategory, Is.EqualTo(mockCategory));
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
32 }
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
33
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
34 [Test()]
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
35 public void TestAddingMultipleCategoriesSetsMainCategory()
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
36 {
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
37 UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
38 MockCategory mockCategory = new MockCategory();
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
39 unitType.AddCategory(mockCategory);
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
40 Category mockCategory2 = new Category("id1", "CatName");
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
41 unitType.AddCategory(mockCategory2);
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
42 Assert.That(unitType.Categories.Length, Is.EqualTo(2));
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
43 Assert.That(unitType.Categories, Has.Member(mockCategory));
24a40c49b6ae Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
44 Assert.That(unitType.Categories, Has.Member(mockCategory2));
46
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 Assert.That(unitType.MainCategory, Is.EqualTo(mockCategory));
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 }
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 }
73308371f9d8 Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49