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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
779ad76c2644 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 126
diff changeset
5 using NUnit.Framework;
779ad76c2644 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 126
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
129
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
8 using IBBoard.WarFoundry.API.Objects.Requirement;
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
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
779ad76c2644 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 126
diff changeset
17 public void TestRaceWithNoUnitTypesHasNoRequirements()
779ad76c2644 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 126
diff changeset
18 {
779ad76c2644 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 126
diff changeset
19 Assert.That(new MockRace().GetRequirements(), Has.Count(0));
129
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
20 }
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
21
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
22 [Test()]
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
23 public void TestRaceWithOneUnitTypeHasNoRequirements()
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
24 {
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
25 MockRace race = new MockRace();
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
26 race.AddUnitType(new MockUnitType());
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
27 Assert.That(race.GetRequirements(), Has.Count(0));
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
28 }
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
29
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
30 [Test()]
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
31 public void TestRaceWithOneUnitTypeWithOneRequirementHasOneRequirement()
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
32 {
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
33 MockRace race = new MockRace();
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
34 MockUnitType unitType = new MockUnitType();
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
35 UnitRequiresAtLeastNUnitsRequirement unitRequirement = new UnitRequiresAtLeastNUnitsRequirement(unitType);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
36 unitType.AddRequirement(unitRequirement);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
37 race.AddUnitType(unitType);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
38 ICollection<IRequirement> raceRequirements = race.GetRequirements();
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
39 Assert.That(raceRequirements, Has.Count(1));
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
40 Assert.That(raceRequirements, Has.All.EqualTo(unitRequirement));
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
41 }
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
42
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
43 [Test()]
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
44 public void TestRaceWithTwoUnitTypesWithMultipleRequirementsHasMultipleRequirements()
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
45 {
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
46 MockRace race = new MockRace();
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
47 MockUnitType unitType1 = new MockUnitType("type1", "Type 1");
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
48 UnitRequiresAtLeastNUnitsRequirement unitRequirement1 = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
49 unitType1.AddRequirement(unitRequirement1);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
50 UnitRequiresNoMoreThanNOfUnitTypeRequirement unitRequirement2 = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
51 unitType1.AddRequirement(unitRequirement2);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
52 race.AddUnitType(unitType1);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
53 MockUnitType unitType2 = new MockUnitType("type2", "Type 2");
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
54 UnitRequiresAtLeastNUnitsRequirement unitRequirement3 = new UnitRequiresAtLeastNUnitsRequirement(unitType2);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
55 unitType2.AddRequirement(unitRequirement3);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
56 race.AddUnitType(unitType2);
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
57 ICollection<IRequirement> raceRequirements = race.GetRequirements();
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
58 Assert.That(raceRequirements, Has.Count(3));
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
59 Assert.That(raceRequirements, Has.Member(unitRequirement1));
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
60 Assert.That(raceRequirements, Has.Member(unitRequirement2));
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
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