annotate API/Objects/RaceTests.cs @ 239:370bec16a364 default tip

Add initial testing for equipment with type (incomplete)
author IBBoard <dev@ibboard.co.uk>
date Sun, 16 Oct 2016 20:29:35 +0100
parents e173c5512067
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 IBBoard.WarFoundry.API.Objects.Requirement;
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
8 using System.Collections.Generic;
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
9 using IBBoard.NUnit;
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
10 using System.Reflection;
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
11 using IBBoard.WarFoundry.API.Factories;
126
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 namespace IBBoard.WarFoundry.API.Objects
6571b6483d2d * Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 {
6571b6483d2d * Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 [TestFixture()]
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
16 public class RaceTests : AbstractEqualityTest<Race>
126
6571b6483d2d * Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
6571b6483d2d * Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 [Test()]
127
779ad76c2644 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 126
diff changeset
19 public void TestRaceWithNoUnitTypesHasNoRequirements()
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
20 {
238
e173c5512067 * Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents: 224
diff changeset
21 Assert.That(new MockRace().GetRequirements(), Has.Count.EqualTo(0));
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
22 }
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 [Test()]
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
25 public void TestRaceWithOneUnitTypeHasNoRequirements()
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
26 {
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
27 MockRace race = new MockRace();
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
28 race.AddUnitType(new MockUnitType());
238
e173c5512067 * Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents: 224
diff changeset
29 Assert.That(race.GetRequirements(), Has.Count.EqualTo(0));
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
30 }
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 [Test()]
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
33 public void TestRaceWithOneUnitTypeWithOneRequirementHasOneRequirement()
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
34 {
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
35 MockRace race = new MockRace();
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
36 MockUnitType unitType = new MockUnitType();
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
37 UnitRequiresAtLeastNUnitsRequirement unitRequirement = new UnitRequiresAtLeastNUnitsRequirement(unitType);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
38 unitType.AddRequirement(unitRequirement);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
39 race.AddUnitType(unitType);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
40 ICollection<IRequirement> raceRequirements = race.GetRequirements();
238
e173c5512067 * Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents: 224
diff changeset
41 Assert.That(raceRequirements, Has.Count.EqualTo(1));
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
42 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
43 }
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 [Test()]
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
46 public void TestRaceWithTwoUnitTypesWithMultipleRequirementsHasMultipleRequirements()
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
47 {
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
48 MockRace race = new MockRace();
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
49 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
50 UnitRequiresAtLeastNUnitsRequirement unitRequirement1 = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
51 unitType1.AddRequirement(unitRequirement1);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
52 UnitRequiresNoMoreThanNOfUnitTypeRequirement unitRequirement2 = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
53 unitType1.AddRequirement(unitRequirement2);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
54 race.AddUnitType(unitType1);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
55 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
56 UnitRequiresAtLeastNUnitsRequirement unitRequirement3 = new UnitRequiresAtLeastNUnitsRequirement(unitType2);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
57 unitType2.AddRequirement(unitRequirement3);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
58 race.AddUnitType(unitType2);
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
59 ICollection<IRequirement> raceRequirements = race.GetRequirements();
238
e173c5512067 * Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents: 224
diff changeset
60 Assert.That(raceRequirements, Has.Count.EqualTo(3));
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
61 Assert.That(raceRequirements, Has.Member(unitRequirement1));
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
62 Assert.That(raceRequirements, Has.Member(unitRequirement2));
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
63 Assert.That(raceRequirements, Has.Member(unitRequirement3));
224
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
64 }
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
65
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
66 [Test()]
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
67 public void TestContainedOnlyUnitsAreNotReturned()
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
68 {
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
69 MockRace race = new MockRace();
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
70 MockUnitType unitType1 = new MockUnitType("type1", "Type 1");
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
71 race.AddUnitType(unitType1);
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
72 MockContainedUnitType unitType2 = new MockContainedUnitType("type2", "Type 2");
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
73 race.AddUnitType(unitType2);
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
74 unitType1.AddContainedUnitType(unitType2);
238
e173c5512067 * Update to v2.6 of NUnit and new syntax/API changes
IBBoard <dev@ibboard.co.uk>
parents: 224
diff changeset
75 Assert.That(race.GetUnitTypes(MockCategory.GetCategory()), Has.Length.EqualTo(1));
224
49480e1a8f90 Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
76 Assert.That(race.GetUnitTypes(MockCategory.GetCategory()), Has.Member(unitType1));
129
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
77 }
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
78
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
79 public override Race GetObject ()
129
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
80 {
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
81 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
82 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
83 return new Race("race", "race", gameSystem, factory);
129
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
84 }
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
85
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
86 public override Race GetSameObject ()
129
95dac00e9330 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 127
diff changeset
87 {
137
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
88 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
89 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
90 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
91 }
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
92
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
93 public override Race GetDifferentObject ()
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
94 {
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
95 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
081b48413f6d Re #140: Add equality methods to WarFoundry objects
IBBoard <dev@ibboard.co.uk>
parents: 129
diff changeset
96 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
97 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
98 }
139
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
99
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
100 public Race GetOtherDifferentObjectWithSubID()
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
101 {
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
102 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
103 GameSystem gameSystem = new GameSystem("system", "system", factory);
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
104 return new Race("race", "subid", "race", gameSystem, factory);
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
105 }
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
106
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
107 public Race GetOtherDifferentObjectWithGameSystem()
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
108 {
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
109 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
110 GameSystem gameSystem = new GameSystem("system2", "system", factory);
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
111 return new Race("race", "race", gameSystem, factory);
3e4864e206ea Re #140: Equality methods
IBBoard <dev@ibboard.co.uk>
parents: 137
diff changeset
112 }
126
6571b6483d2d * Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 }
6571b6483d2d * Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 }
6571b6483d2d * Set target framework to v2.0...AGAIN
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115