Mercurial > repos > IBBoard.WarFoundry.API.Tests
annotate API/Objects/RaceTests.cs @ 176:9a1763af5fd2
Re #338: WarFoundry.API - Save System Data
* Add tests for saving point names
* Add expected values for new tests
* Add points names to existing expected values (because we don't know if they were default or not)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 26 Oct 2011 15:40:52 +0100 |
parents | 2ae80631ec9c |
children | 49480e1a8f90 |
rev | line source |
---|---|
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
1 // This file (RaceTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard |
126
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; |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
5 using NUnit.Framework; |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
6 using IBBoard.WarFoundry.API.Objects.Mock; |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
7 using NUnit.Framework.SyntaxHelpers; |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
8 using IBBoard.WarFoundry.API.Objects.Requirement; |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
9 using System.Collections.Generic; |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
10 using IBBoard.NUnit; |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
11 using System.Reflection; |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
12 using IBBoard.WarFoundry.API.Factories; |
126
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 namespace IBBoard.WarFoundry.API.Objects |
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 [TestFixture()] |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
17 public class RaceTests : AbstractEqualityTest<Race> |
126
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 { |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 [Test()] |
127 | 20 public void TestRaceWithNoUnitTypesHasNoRequirements() |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
21 { |
127 | 22 Assert.That(new MockRace().GetRequirements(), Has.Count(0)); |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
23 } |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
24 |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
25 [Test()] |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
26 public void TestRaceWithOneUnitTypeHasNoRequirements() |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
27 { |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
28 MockRace race = new MockRace(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
29 race.AddUnitType(new MockUnitType()); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
30 Assert.That(race.GetRequirements(), Has.Count(0)); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
31 } |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
32 |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
33 [Test()] |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
34 public void TestRaceWithOneUnitTypeWithOneRequirementHasOneRequirement() |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
35 { |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
36 MockRace race = new MockRace(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
37 MockUnitType unitType = new MockUnitType(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
38 UnitRequiresAtLeastNUnitsRequirement unitRequirement = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
39 unitType.AddRequirement(unitRequirement); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
40 race.AddUnitType(unitType); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
41 ICollection<IRequirement> raceRequirements = race.GetRequirements(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
42 Assert.That(raceRequirements, Has.Count(1)); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
43 Assert.That(raceRequirements, Has.All.EqualTo(unitRequirement)); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
44 } |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
45 |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
46 [Test()] |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
47 public void TestRaceWithTwoUnitTypesWithMultipleRequirementsHasMultipleRequirements() |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
48 { |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
49 MockRace race = new MockRace(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
50 MockUnitType unitType1 = new MockUnitType("type1", "Type 1"); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
51 UnitRequiresAtLeastNUnitsRequirement unitRequirement1 = new UnitRequiresAtLeastNUnitsRequirement(unitType1); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
52 unitType1.AddRequirement(unitRequirement1); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
53 UnitRequiresNoMoreThanNOfUnitTypeRequirement unitRequirement2 = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
54 unitType1.AddRequirement(unitRequirement2); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
55 race.AddUnitType(unitType1); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
56 MockUnitType unitType2 = new MockUnitType("type2", "Type 2"); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
57 UnitRequiresAtLeastNUnitsRequirement unitRequirement3 = new UnitRequiresAtLeastNUnitsRequirement(unitType2); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
58 unitType2.AddRequirement(unitRequirement3); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
59 race.AddUnitType(unitType2); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
60 ICollection<IRequirement> raceRequirements = race.GetRequirements(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
61 Assert.That(raceRequirements, Has.Count(3)); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
62 Assert.That(raceRequirements, Has.Member(unitRequirement1)); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
63 Assert.That(raceRequirements, Has.Member(unitRequirement2)); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
64 Assert.That(raceRequirements, Has.Member(unitRequirement3)); |
129 | 65 } |
66 | |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
67 public override Race GetObject () |
129 | 68 { |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
69 DummyWarFoundryFactory factory = new DummyWarFoundryFactory(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
70 GameSystem gameSystem = new GameSystem("system", "system", factory); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
71 return new Race("race", "race", gameSystem, factory); |
129 | 72 } |
73 | |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
74 public override Race GetSameObject () |
129 | 75 { |
137
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
76 DummyWarFoundryFactory factory = new DummyWarFoundryFactory(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
77 GameSystem gameSystem = new GameSystem("system", "system", factory); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
78 return new Race("race", "race", gameSystem, factory); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
79 } |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
80 |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
81 public override Race GetDifferentObject () |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
82 { |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
83 DummyWarFoundryFactory factory = new DummyWarFoundryFactory(); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
84 GameSystem gameSystem = new GameSystem("system2", "another system", factory); |
081b48413f6d
Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents:
129
diff
changeset
|
85 return new Race("race2", "other race", gameSystem, factory); |
126
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 } |
139 | 87 |
88 public Race GetOtherDifferentObjectWithSubID() | |
89 { | |
90 DummyWarFoundryFactory factory = new DummyWarFoundryFactory(); | |
91 GameSystem gameSystem = new GameSystem("system", "system", factory); | |
92 return new Race("race", "subid", "race", gameSystem, factory); | |
93 } | |
94 | |
95 public Race GetOtherDifferentObjectWithGameSystem() | |
96 { | |
97 DummyWarFoundryFactory factory = new DummyWarFoundryFactory(); | |
98 GameSystem gameSystem = new GameSystem("system2", "system", factory); | |
99 return new Race("race", "race", gameSystem, factory); | |
100 } | |
126
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 } |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 } |
6571b6483d2d
* Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 |