annotate API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs @ 210:649759343da5

Re #379: Fix validation of requirements to check for unit * Tidy up tests to reduce replication and fix copy-and-paste inconsistencies
author IBBoard <dev@ibboard.co.uk>
date Sat, 25 Feb 2012 16:36:20 +0000
parents c323770e61c2
children
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()]
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
15 public class RequiresAtLeastNUnitsRequirementTest : AbstractEqualityTest<RequiresAtLeastNUnitsRequirement<UnitType>>
138
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;
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
18 private UnitType allowedUnitType;
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
19 private UnitType unitType1;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
20 private UnitType unitType2;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
21 private UnitType unitType3;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
22
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
23 [TestFixtureSetUp()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
24 public void SetupRace()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
25 {
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 146
diff changeset
26 mockRace = new MockRace();
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
27 allowedUnitType = new MockUnitType("allowed", "Allowed Type");
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
28 mockRace.AddUnitType(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
29 unitType1 = new MockUnitType("type1", "Unit Type 1");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
30 mockRace.AddUnitType(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
31 unitType2 = new MockUnitType("type2", "Unit Type 2");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
32 mockRace.AddUnitType(unitType2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
33 unitType3 = new MockUnitType("type3", "Unit Type 3");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
34 mockRace.AddUnitType(unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
35 }
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
36
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
37 [Test()]
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
38 public void TestAddingUnrelatedUnitWithNoUnitsAndOneUnitTypeRequired()
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
39 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
40 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
41 Unit unit = CreateUnitOfType(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
42 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType2);
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
43 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
44 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
47 public void TestAddingOneUnitWithOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
48 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
49 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
50 Unit unit = CreateUnitOfType(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
51 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
52 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
53 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
56 public void TestAddingUnitWithOneUnitAndTwoOfUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
57 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
58 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
59 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
60 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
61 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
62 Unit unit = CreateUnitOfType(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
63 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
64 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
67 public void TestAddingUnrelatedUnitTypeWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
68 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
69 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
70 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType2);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
71 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
72 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
75 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
76 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
77 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
78 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
79 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
80 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
83 public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
84 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
85 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
86 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
87 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
88 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
89 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
92 public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
93 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
94 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
95 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType2, unitType3);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
96 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
97 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
100 public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
101 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
102 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
103 AddUnitOfTypeToArmy(unitType3, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
104 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType2, unitType3);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
105 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
106 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
109 public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
110 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
111 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
112 AddUnitOfTypeToArmy(unitType2, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
113 AddUnitOfTypeToArmy(unitType3, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
114 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType2, unitType3);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
115 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
116 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
119 public void TestAddingOneOfUnitTypeWithTwoOfOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
120 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
121 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
122 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
123 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
124 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
125 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
128 public void TestAddingOneUnitTypeWithOneUnitAndTwoOfOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
129 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
130 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
131 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
132 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
133 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
134 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
135 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
138 public void TestAddingUnitTypeRequirementWithNoNumberDefaultsToHavingOne()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
139 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
140 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
141 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
142 req.AddUnitTypeRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
143 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
144 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
147 public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
148 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
149 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
150 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
151 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
152 }
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 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
155 public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
156 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
157 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
158 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
159 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
160 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
161 }
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 [Test]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
164 public void TestAddingMinNumberUnitTypePassesRequirement()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
165 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
166 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
167 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
168 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
169 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
170 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
171 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
172 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
173
141
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
174 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
175 public void TestValidationMessageIsBlankForPass()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
176 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
177 Army army = new Army(mockRace, "Test", 1000);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
178 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
179 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
141
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
180 Assert.That(req.GetValidationMessage(army), Is.Empty);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
181 }
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 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
184 public void TestValidationMessageIsCorrectForFailWithOneUnitRequired()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
185 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
186 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
187 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
141
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
188 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
189 }
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 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
192 public void TestValidationMessageIsCorrectForFailWithTwoOfOneUnitRequired()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
193 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
194 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
195 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
141
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
196 req.AddUnitTypeRequirement(unitType1, 2);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
197 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
198 }
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 [Test]
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
201 public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequired()
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
202 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
203 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
204 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
141
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
205 req.AddUnitTypeRequirement(unitType1);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
206 req.AddUnitTypeRequirement(unitType2);
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
207 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
208 }
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 140
diff changeset
209
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
210 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
211 public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequiredWithOneUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
212 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
213 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
214 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
215 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
216 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
217 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
218 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
219 }
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 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
222 public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequiredWithOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
223 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
224 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
225 AddUnitOfTypeToArmy(unitType2, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
226 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
227 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
228 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
229 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
230 }
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 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
233 public void TestAllowsAddingMessageIsBlankForPass()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
234 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
235 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
236 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
237 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType, unitType1);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
238 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
239 }
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 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
242 public void TestAllowsAddingMessageIsCorrectForFailWithTwoOfOneUnitRequired()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
243 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
244 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
245 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
246 req.AddUnitTypeRequirement(unitType1, 2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
247 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
248 }
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 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
251 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequired()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
252 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
253 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
254 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
255 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
256 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
257 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
258 }
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 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
261 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
262 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
263 Army army = new Army(mockRace, "Test", 1000);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
264 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
265 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
266 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
267 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
268 }
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 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
271 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredWithOneUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
272 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
273 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
274 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
275 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
276 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
277 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
278 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
279 }
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 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
282 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredWithOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
283 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
284 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
285 AddUnitOfTypeToArmy(unitType2, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
286 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
287 req.AddUnitTypeRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
288 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
289 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
290 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
291
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
292 private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
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 army.AddUnit(CreateUnitOfType(unitType, 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
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
297 private static Unit CreateUnitOfType(UnitType unitType, Army army)
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
298 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
299 return new Unit(unitType, army.GetCategory(unitType.MainCategory));
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
300 }
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
301
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
302 public override RequiresAtLeastNUnitsRequirement<UnitType> GetObject()
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
303 {
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
304 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
305 req.AddUnitTypeRequirement(unitType1, 2);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
306 return req;
110
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
307 }
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
308
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
309 public override RequiresAtLeastNUnitsRequirement<UnitType> GetSameObject()
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
310 {
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
311 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
312 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
313 return req;
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
314 }
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
315
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
316 public override RequiresAtLeastNUnitsRequirement<UnitType> GetDifferentObject()
124
14a007cf2446 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
317 {
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
318 RequiresAtLeastNUnitsRequirement<UnitType> req = new RequiresAtLeastNUnitsRequirement<UnitType>(allowedUnitType);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
319 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
320 GameSystem gameSystem = new GameSystem("system", "system", factory);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
321 Race race = new Race("race", "race", gameSystem, factory);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
322 req.AddUnitTypeRequirement(new UnitType("id2", "Type 2", race), 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
323 return req;
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
324 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
325 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
326 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
327