Mercurial > repos > IBBoard.WarFoundry.API.Tests
annotate API/Objects/RaceTests.cs @ 129:95dac00e9330
Re #27: Unit requirements
* Test getting all unit requirements for race
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 09 Apr 2011 19:13:42 +0000 |
parents | 779ad76c2644 |
children | 081b48413f6d |
rev | line source |
---|---|
126
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (RaceTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
6571b6483d2d
* Set target framework to v2.0...AGAIN
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. |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 using System; |
127 | 5 using NUnit.Framework; |
6 using IBBoard.WarFoundry.API.Objects.Mock; | |
129 | 7 using NUnit.Framework.SyntaxHelpers; |
8 using IBBoard.WarFoundry.API.Objects.Requirement; | |
9 using System.Collections.Generic; | |
126
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 namespace IBBoard.WarFoundry.API.Objects |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 { |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 [TestFixture()] |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 public class RaceTests |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 [Test()] |
127 | 17 public void TestRaceWithNoUnitTypesHasNoRequirements() |
18 { | |
19 Assert.That(new MockRace().GetRequirements(), Has.Count(0)); | |
129 | 20 } |
21 | |
22 [Test()] | |
23 public void TestRaceWithOneUnitTypeHasNoRequirements() | |
24 { | |
25 MockRace race = new MockRace(); | |
26 race.AddUnitType(new MockUnitType()); | |
27 Assert.That(race.GetRequirements(), Has.Count(0)); | |
28 } | |
29 | |
30 [Test()] | |
31 public void TestRaceWithOneUnitTypeWithOneRequirementHasOneRequirement() | |
32 { | |
33 MockRace race = new MockRace(); | |
34 MockUnitType unitType = new MockUnitType(); | |
35 UnitRequiresAtLeastNUnitsRequirement unitRequirement = new UnitRequiresAtLeastNUnitsRequirement(unitType); | |
36 unitType.AddRequirement(unitRequirement); | |
37 race.AddUnitType(unitType); | |
38 ICollection<IRequirement> raceRequirements = race.GetRequirements(); | |
39 Assert.That(raceRequirements, Has.Count(1)); | |
40 Assert.That(raceRequirements, Has.All.EqualTo(unitRequirement)); | |
41 } | |
42 | |
43 [Test()] | |
44 public void TestRaceWithTwoUnitTypesWithMultipleRequirementsHasMultipleRequirements() | |
45 { | |
46 MockRace race = new MockRace(); | |
47 MockUnitType unitType1 = new MockUnitType("type1", "Type 1"); | |
48 UnitRequiresAtLeastNUnitsRequirement unitRequirement1 = new UnitRequiresAtLeastNUnitsRequirement(unitType1); | |
49 unitType1.AddRequirement(unitRequirement1); | |
50 UnitRequiresNoMoreThanNOfUnitTypeRequirement unitRequirement2 = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1); | |
51 unitType1.AddRequirement(unitRequirement2); | |
52 race.AddUnitType(unitType1); | |
53 MockUnitType unitType2 = new MockUnitType("type2", "Type 2"); | |
54 UnitRequiresAtLeastNUnitsRequirement unitRequirement3 = new UnitRequiresAtLeastNUnitsRequirement(unitType2); | |
55 unitType2.AddRequirement(unitRequirement3); | |
56 race.AddUnitType(unitType2); | |
57 ICollection<IRequirement> raceRequirements = race.GetRequirements(); | |
58 Assert.That(raceRequirements, Has.Count(3)); | |
59 Assert.That(raceRequirements, Has.Member(unitRequirement1)); | |
60 Assert.That(raceRequirements, Has.Member(unitRequirement2)); | |
61 Assert.That(raceRequirements, Has.Member(unitRequirement3)); | |
126
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 } |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 } |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 } |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 |