annotate API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs @ 102:a3bc8174299f

Re #27: Define unit requirements * First test for first new style requirement * Update some of the Mock objects to add a few more required elements (mainly Category)
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Mar 2011 17:04:09 +0000
parents
children c6562eb62d04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitRequiresAtLeastNUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
a3bc8174299f Re #27: Define unit requirements
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.
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects.Requirements
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 [TestFixture()]
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public class UnitRequiresAtLeastNUnitsRequirementTest
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [Test()]
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 public void TestWithNoUnits()
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 MockRace mockRace = MockRace.GetMockRace();
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 UnitType unitType1 = new MockUnitType("type1", "Unit Type 1");
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 mockRace.AddUnitType(unitType1);
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 UnitType unitType2 = new MockUnitType("type2", "Unit Type 2");
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 mockRace.AddUnitType(unitType2);
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 Army army = new Army(mockRace, "Test", 1000);
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1, unitType2);
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 Unit unit = new Unit(unitType1, army.GetCategory(unitType1.MainCategory));
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 Assert.That(req.CanAddToArmy(unit, army), Is.False);
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29