annotate API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs @ 116:49fb69ea13f2

Re #27: Unit requirements * Switch to enumeration and update tests as appropriate
author IBBoard <dev@ibboard.co.uk>
date Mon, 04 Apr 2011 19:05:47 +0000
parents 788ef54f5b5a
children 14a007cf2446
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
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects.Requirement
102
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()]
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
12 public class RequiresAtLeastNUnitsRequirementTest
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
13 {
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
14 private MockRace mockRace;
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
15 private UnitType unitType1;
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
16 private UnitType unitType2;
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
17 private UnitType unitType3;
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
18
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
19 [TestFixtureSetUp()]
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
20 public void SetupRace()
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 {
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
22 mockRace = MockRace.GetMockRace();
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
23 unitType1 = new MockUnitType("type1", "Unit Type 1");
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 mockRace.AddUnitType(unitType1);
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
25 unitType2 = new MockUnitType("type2", "Unit Type 2");
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 mockRace.AddUnitType(unitType2);
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
27 unitType3 = new MockUnitType("type3", "Unit Type 3");
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
28 mockRace.AddUnitType(unitType3);
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
29 }
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
30
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
31 [Test()]
104
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
32 public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequired()
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
33 {
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 Army army = new Army(mockRace, "Test", 1000);
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
35 Unit unit = CreateUnitOfType(unitType1, army);
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
36 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
37 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
38 }
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
39
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
40 [Test()]
104
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
41 public void TestAddingUnitWithOneUnitAndOneUnitTypeRequired()
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
42 {
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
43 Army army = new Army(mockRace, "Test", 1000);
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
44 AddUnitOfTypeToArmy(unitType2, army);
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
45 Unit unit = CreateUnitOfType(unitType1, army);
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
46 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
47 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
48 }
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
49
104
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
50 [Test()]
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
51 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
52 {
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
53 Army army = new Army(mockRace, "Test", 1000);
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
54 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
55 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
104
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
56 }
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
57
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
58 [Test()]
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
59 public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
60 {
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
61 Army army = new Army(mockRace, "Test", 1000);
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
62 AddUnitOfTypeToArmy(unitType2, army);
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
63 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
64 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
104
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
65 }
782494137b58 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 103
diff changeset
66
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
67 [Test()]
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
68 public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
69 {
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
70 Army army = new Army(mockRace, "Test", 1000);
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
71 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
72 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
73 }
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
74
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
75 [Test()]
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
76 public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
77 {
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
78 Army army = new Army(mockRace, "Test", 1000);
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
79 AddUnitOfTypeToArmy(unitType2, army);
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
80 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
81 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
82 }
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
83
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
84 [Test()]
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
85 public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
86 {
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
87 Army army = new Army(mockRace, "Test", 1000);
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
88 AddUnitOfTypeToArmy(unitType2, army);
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
89 AddUnitOfTypeToArmy(unitType3, army);
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
90 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
91 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
92 }
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
93
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
94 [Test()]
108
74bfe8b325d6 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 107
diff changeset
95 public void TestAddingUnitTypeWithOneUnitAndTwoOfOneUnitTypeRequired()
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
96 {
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
97 Army army = new Army(mockRace, "Test", 1000);
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
98 AddUnitOfTypeToArmy(unitType2, army);
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
99 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
100 req.AddUnitTypeRequirement(unitType2, 2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
101 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
102 }
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
103
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
104 [Test()]
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
105 public void TestAddingUnitTypeWithTwoUnitsAndTwoOfOneUnitTypeRequired()
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
106 {
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
107 Army army = new Army(mockRace, "Test", 1000);
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
108 AddUnitOfTypeToArmy(unitType2, army);
108
74bfe8b325d6 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 107
diff changeset
109 AddUnitOfTypeToArmy(unitType2, army);
74bfe8b325d6 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 107
diff changeset
110 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
74bfe8b325d6 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 107
diff changeset
111 req.AddUnitTypeRequirement(unitType2, 2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
112 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
113 }
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
114
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
115 [Test()]
110
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
116 public void TestAddingUnitTypeRequirementWithNoNumberDefaultsToHavingOne()
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
117 {
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
118 Army army = new Army(mockRace, "Test", 1000);
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
119 AddUnitOfTypeToArmy(unitType2, army);
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
120 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
121 req.AddUnitTypeRequirement(unitType2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
122 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
110
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
123 }
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
124
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
125 [Test()]
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
126 public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
127 {
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
128 Army army = new Army(mockRace, "Test", 1000);
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
129 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
130 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
131 }
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
132
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
133 [Test()]
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
134 public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
135 {
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
136 Army army = new Army(mockRace, "Test", 1000);
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
137 AddUnitOfTypeToArmy(unitType2, army);
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
138 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
116
49fb69ea13f2 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 110
diff changeset
139 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
140 }
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
141
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
142 private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
143 {
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
144 army.AddUnit(CreateUnitOfType(unitType, army));
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 }
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
146
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
147 private static Unit CreateUnitOfType(UnitType unitType, Army army)
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
148 {
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
149 return new Unit(unitType, army.GetCategory(unitType.MainCategory));
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
150 }
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153