annotate API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs @ 188:0762766bd3f2

Re #350: Add requirement to allow N of unit for specific other units * Remove static access to mock race - it broke tests * Add first tests for new requirement
author IBBoard <dev@ibboard.co.uk>
date Tue, 29 Nov 2011 20:56:34 +0000
parents 8c519a44e699
children c323770e61c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
1 // This file (UnitRequiresAtLeastNUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
102
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;
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
5 using NUnit.Framework;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
8 using System.Reflection;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
9 using IBBoard.NUnit;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
10 using IBBoard.WarFoundry.API.Factories;
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
12 namespace IBBoard.WarFoundry.API.Objects.Requirement
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [TestFixture()]
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
15 public class RequiresAtLeastNUnitsRequirementTest : AbstractEqualityTest<RequiresAtLeastNUnitsRequirement>
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
16 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
17 private MockRace mockRace;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
18 private UnitType unitType1;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
19 private UnitType unitType2;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
20 private UnitType unitType3;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
21
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
22 [TestFixtureSetUp()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
23 public void SetupRace()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
24 {
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 146
diff changeset
25 mockRace = new MockRace();
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
26 unitType1 = new MockUnitType("type1", "Unit Type 1");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
27 mockRace.AddUnitType(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
28 unitType2 = new MockUnitType("type2", "Unit Type 2");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
29 mockRace.AddUnitType(unitType2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
30 unitType3 = new MockUnitType("type3", "Unit Type 3");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
31 mockRace.AddUnitType(unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
32 }
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
33
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
34 [Test()]
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
35 public void TestAddingUnrelatedUnitWithNoUnitsAndOneUnitTypeRequired()
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
36 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
37 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
38 Unit unit = CreateUnitOfType(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
39 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
40 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.NotApplicable));
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
41 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
42
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
43 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
44 public void TestAddingOneUnitWithOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
45 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
46 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
47 Unit unit = CreateUnitOfType(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
48 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
49 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
50 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
51
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
52 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
53 public void TestAddingUnitWithOneUnitAndTwoOfUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
54 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
55 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
56 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
57 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
58 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
59 Unit unit = CreateUnitOfType(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
60 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
61 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
62
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
63 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
64 public void TestAddingUnrelatedUnitTypeWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
65 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
66 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
67 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
68 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.NotApplicable));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
69 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
70
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
71 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
72 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
73 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
74 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
75 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
76 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
77 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
78
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
79 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
80 public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
81 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
82 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
83 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
84 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
85 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
86 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
87
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
88 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
89 public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
90 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
91 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
92 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
93 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
94 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
95
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
96 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
97 public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
98 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
99 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
100 AddUnitOfTypeToArmy(unitType3, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
101 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
102 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
103 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
104
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
105 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
106 public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
107 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
108 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
109 AddUnitOfTypeToArmy(unitType2, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
110 AddUnitOfTypeToArmy(unitType3, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
111 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
112 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
113 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
114
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
115 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
116 public void TestAddingOneOfUnitTypeWithTwoOfOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
117 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
118 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
119 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
120 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
121 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
122 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
123
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
124 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
125 public void TestAddingOneUnitTypeWithOneUnitAndTwoOfOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
126 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
127 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
128 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
129 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
130 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
131 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
132 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
133
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
134 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
135 public void TestAddingUnitTypeRequirementWithNoNumberDefaultsToHavingOne()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
136 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
137 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
138 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
139 req.AddUnitTypeRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
140 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
141 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
142
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
143 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
144 public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
145 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
146 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
147 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
148 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
149 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
150
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
151 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
152 public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
153 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
154 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
155 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
156 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
157 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
158 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
159
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
160 [Test]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
161 public void TestAddingMinNumberUnitTypePassesRequirement()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
162 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
163 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
164 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
165 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
166 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
167 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
168 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
169 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
170
141
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
171 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
172 public void TestValidationMessageIsBlankForPass()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
173 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
174 Army army = new Army(mockRace, "Test", 1000);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
175 AddUnitOfTypeToArmy(unitType1, army);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
176 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
177 Assert.That(req.GetValidationMessage(army), Is.Empty);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
178 }
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
179
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
180 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
181 public void TestValidationMessageIsCorrectForFailWithOneUnitRequired()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
182 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
183 Army army = new Army(mockRace, "Test", 1000);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
184 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
185 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType1.Name + " (have 0)."));
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
186 }
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
187
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
188 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
189 public void TestValidationMessageIsCorrectForFailWithTwoOfOneUnitRequired()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
190 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
191 Army army = new Army(mockRace, "Test", 1000);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
192 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
193 req.AddUnitTypeRequirement(unitType1, 2);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
194 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType1.Name + " (have 0)."));
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
195 }
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
196
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
197 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
198 public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequired()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
199 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
200 Army army = new Army(mockRace, "Test", 1000);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
201 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
202 req.AddUnitTypeRequirement(unitType1);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
203 req.AddUnitTypeRequirement(unitType2);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
204 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType1.Name + " (have 0); 1 × " + unitType2.Name + " (have 0)."));
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
205 }
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
206
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
207 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
208 public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequiredWithOneUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
209 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
210 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
211 AddUnitOfTypeToArmy(unitType1, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
212 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
213 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
214 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
215 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " (have 0)."));
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
216 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
217
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
218 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
219 public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequiredWithOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
220 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
221 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
222 AddUnitOfTypeToArmy(unitType2, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
223 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
224 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
225 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
226 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType1.Name + " (have 0)."));
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
227 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
228
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
229 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
230 public void TestAllowsAddingMessageIsBlankForPass()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
231 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
232 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
233 AddUnitOfTypeToArmy(unitType1, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
234 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
235 Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.Empty);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
236 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
237
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
238 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
239 public void TestAllowsAddingMessageIsCorrectForFailWithTwoOfOneUnitRequired()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
240 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
241 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
242 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
243 req.AddUnitTypeRequirement(unitType1, 2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
244 Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.EqualTo("Army must contain: 2 × " + unitType1.Name + " (would have 1)."));
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
245 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
246
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
247 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
248 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequired()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
249 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
250 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
251 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
252 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
253 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
254 Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " (would have 0)."));
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
255 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
256
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
257 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
258 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
259 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
260 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
261 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
262 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
263 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
264 Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 1 × " + unitType1.Name + " (would have 0)."));
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
265 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
266
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
267 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
268 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredWithOneUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
269 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
270 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
271 AddUnitOfTypeToArmy(unitType1, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
272 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
273 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
274 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
275 Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " (would have 0)."));
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
276 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
277
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
278 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
279 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredWithOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
280 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
281 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
282 AddUnitOfTypeToArmy(unitType2, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
283 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
284 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
285 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
286 Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 1 × " + unitType1.Name + " (would have 0)."));
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
287 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
288
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
289 private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
290 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
291 army.AddUnit(CreateUnitOfType(unitType, army));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
292 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
293
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
294 private static Unit CreateUnitOfType(UnitType unitType, Army army)
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
295 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
296 return new Unit(unitType, army.GetCategory(unitType.MainCategory));
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
297 }
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
298
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
299 public override RequiresAtLeastNUnitsRequirement GetObject ()
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
300 {
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
301 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
302 req.AddUnitTypeRequirement(unitType1, 2);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
303 return req;
110
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
304 }
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
305
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
306 public override RequiresAtLeastNUnitsRequirement GetSameObject ()
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
307 {
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
308 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
309 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
310 return req;
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
311 }
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
312
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
313 public override RequiresAtLeastNUnitsRequirement GetDifferentObject ()
124
14a007cf2446 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
314 {
14a007cf2446 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
315 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
316 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
317 GameSystem gameSystem = new GameSystem("system", "system", factory);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
318 Race race = new Race("race", "race", gameSystem, factory);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
319 req.AddUnitTypeRequirement(new UnitType("id2", "Type 2", race), 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
320 return req;
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
321 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
322 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
323 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
324