annotate API/Objects/Requirement/RequiresNUnitsForMUnitsRequirementTest.cs @ 207:27f163bf884a

Re #379: Fix validation of requirements to check for unit * Update checked text to match new, cleaner text
author IBBoard <dev@ibboard.co.uk>
date Tue, 31 Jan 2012 20:59:15 +0000
parents 49e50238c380
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitRequiresNUnitsForMUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
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.
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using System.Reflection;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.NUnit;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 using IBBoard.WarFoundry.API.Factories;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 namespace IBBoard.WarFoundry.API.Objects.Requirement
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [TestFixture()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 public class RequiresNUnitsForMUnitsRequirementTest : AbstractEqualityTest<RequiresNUnitsForMUnitsRequirement>
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 private MockRace mockRace;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 private UnitType unitType1;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 private UnitType unitType2;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 private UnitType unitType3;
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
21 private UnitType unitType4;
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 [TestFixtureSetUp()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 public void SetupRace()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 mockRace = MockRace.GetMockRace();
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 unitType1 = new MockUnitType("type1", "Unit Type 1");
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 mockRace.AddUnitType(unitType1);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 unitType2 = new MockUnitType("type2", "Unit Type 2");
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 mockRace.AddUnitType(unitType2);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 unitType3 = new MockUnitType("type3", "Unit Type 3");
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 mockRace.AddUnitType(unitType3);
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
33 unitType4 = new MockUnitType("type4", "Unit Type 4");
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
34 mockRace.AddUnitType(unitType4);
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 public void TestAddingUnrelatedUnitWithNoUnitsAndOneUnitTypeRequiredIsNA()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 Army army = new Army(mockRace, "Test", 1000);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 Unit unit = CreateUnitOfType(unitType3, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.NotApplicable));
189
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
44 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 public void TestAddingOneUnitWithOneUnitTypeRequiredAndOneUnitOfTypePasses()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 Army army = new Army(mockRace, "Test", 1000);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 AddUnitOfTypeToArmy(unitType2, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 Unit unit = CreateUnitOfType(unitType1, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
189
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
55 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 public void TestAddingOneUnitWithOneUnitTypeRequiredAndNoUnitOfTypeFails()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 Army army = new Army(mockRace, "Test", 1000);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 Unit unit = CreateUnitOfType(unitType1, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
65 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."));
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 [Test()]
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
69 public void TestAddingOneUnitWithTwoDifferentUnitTypesRequiredAndNoUnitOfOneTypeFails()
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
70 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
71 Army army = new Army(mockRace, "Test", 1000);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
72 AddUnitOfTypeToArmy(unitType2, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
73 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
74 req.AddUnitTypeRequirement(unitType2);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
75 req.AddUnitTypeRequirement(unitType3);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
76 Unit unit = CreateUnitOfType(unitType1, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
77 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
78 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."));
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
79 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
80
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
81 [Test()]
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 public void TestAddingTwoUnitsWithOneUnitTypeRequiredAndOneUnitOfTypeFails()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 Army army = new Army(mockRace, "Test", 1000);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 AddUnitOfTypeToArmy(unitType2, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 AddUnitOfTypeToArmy(unitType1, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 Unit unit = CreateUnitOfType(unitType1, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
90 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2)."));
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 public void TestAddingTwoUnitsWithTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypePasses()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 Army army = new Army(mockRace, "Test", 1000);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 AddUnitOfTypeToArmy(unitType2, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 AddUnitOfTypeToArmy(unitType1, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 req.AddUnitTypeRequirement(unitType2, 1, 2);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 Unit unit = CreateUnitOfType(unitType1, army);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
189
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
103 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
104 }
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
105
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
106 [Test()]
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
107 public void TestAddingTwoUnitsWithTwoAllowedAndOneAllowedForDifferentTypesFails()
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
108 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
109 Army army = new Army(mockRace, "Test", 1000);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
110 AddUnitOfTypeToArmy(unitType2, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
111 AddUnitOfTypeToArmy(unitType3, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
112 AddUnitOfTypeToArmy(unitType1, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
113 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
114 req.AddUnitTypeRequirement(unitType2, 1, 2);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
115 req.AddUnitTypeRequirement(unitType3, 1, 1);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
116 Unit unit = CreateUnitOfType(unitType1, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
117 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
118 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2)."));
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
119 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
120
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
121 [Test()]
195
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
122 public void TestAddingSecondUnitsWithOneAllowedForTwoTypesFails()
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
123 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
124 Army army = new Army(mockRace, "Test", 1000);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
125 AddUnitOfTypeToArmy(unitType2, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
126 AddUnitOfTypeToArmy(unitType3, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
127 AddUnitOfTypeToArmy(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
128 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
129 req.AddUnitTypeRequirement(unitType2, 1, 1);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
130 req.AddUnitTypeRequirement(unitType3, 1, 1);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
131 Unit unit = CreateUnitOfType(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
132 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
133 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2)."));
195
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
134 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
135
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
136 [Test()]
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
137 public void TestAddingSecondUnitsWithOneAllowedForTwoTypesFails_ShorthandMethod()
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
138 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
139 Army army = new Army(mockRace, "Test", 1000);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
140 AddUnitOfTypeToArmy(unitType2, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
141 AddUnitOfTypeToArmy(unitType3, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
142 AddUnitOfTypeToArmy(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
143 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2, unitType3);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
144 Unit unit = CreateUnitOfType(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
145 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
146 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2)."));
195
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
147 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
148
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
149 [Test()]
189
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
150 public void TestAddingThreeUnitsWithTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypeFails()
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
151 {
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
152 Army army = new Army(mockRace, "Test", 1000);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
153 AddUnitOfTypeToArmy(unitType2, army);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
154 AddUnitOfTypeToArmy(unitType1, army);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
155 AddUnitOfTypeToArmy(unitType1, army);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
156 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
157 req.AddUnitTypeRequirement(unitType2, 1, 2);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
158 Unit unit = CreateUnitOfType(unitType1, army);
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
159 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
160 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 1 for 3)."));
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
163 [Test()]
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
164 public void TestAddingOneUnitWithThreeOfUnitTypeAllowedForTwoOfUnitTypeRequiredAndOneUnitOfTypeFails()
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
165 {
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
166 Army army = new Army(mockRace, "Test", 1000);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
167 AddUnitOfTypeToArmy(unitType2, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
168 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
169 req.AddUnitTypeRequirement(unitType2, 2, 3);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
170 Unit unit = CreateUnitOfType(unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
171 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
172 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (would have 1 for 1)."));
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
173 }
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
174
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
175 [Test()]
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
176 public void TestAddingSecondUnitWithThreeOfUnitTypeAllowedForTwoOfUnitTypeRequiredAndOneUnitOfTypeFails()
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
177 {
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
178 Army army = new Army(mockRace, "Test", 1000);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
179 AddUnitOfTypeToArmy(unitType2, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
180 AddUnitOfTypeToArmy(unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
181 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
182 req.AddUnitTypeRequirement(unitType2, 2, 3);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
183 Unit unit = CreateUnitOfType(unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
184 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
185 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (would have 1 for 2)."));
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
186 }
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
187
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
188 [Test()]
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
189 public void TestAddingFourthUnitWithThreeOfUnitTypeAllowedForTwoOfUnitTypeRequiredAndThreeUnitsOfTypeFails()
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
190 {
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
191 Army army = new Army(mockRace, "Test", 1000);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
192 AddUnitsOfTypeToArmy(3, unitType2, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
193 AddUnitsOfTypeToArmy(3, unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
194 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
195 req.AddUnitTypeRequirement(unitType2, 2, 3);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
196 Unit unit = CreateUnitOfType(unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
197 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
198 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (would have 3 for 4)."));
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
199 }
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
200
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
201 [Test()]
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
202 public void TestAddingUnrelatedUnitWithNoUnitsAndTwoCombinedUnitTypesRequiredIsNA()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
203 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
204 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
205 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
206 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
207 Unit unit = CreateUnitOfType(unitType4, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
208 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.NotApplicable));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
209 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
210 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
211
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
212 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
213 public void TestAddingOneUnitWithTwoUnitTypeComboRequiredAndUnitOfOneTypePasses()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
214 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
215 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
216 AddUnitOfTypeToArmy(unitType2, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
217 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
218 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
219 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
220 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
221 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
222 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
223
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
224 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
225 public void TestAddingOneUnitWithTwoUnitTypeComboRequiredAndUnitOfOtherTypePasses()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
226 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
227 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
228 AddUnitOfTypeToArmy(unitType3, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
229 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
230 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
231 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
232 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
233 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
234 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
235
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
236 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
237 public void TestAddingTwoUnitsWithTwoUnitTypeComboRequiredAndOneUnitOfBothTypesPasses()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
238 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
239 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
240 AddUnitOfTypeToArmy(unitType3, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
241 AddUnitOfTypeToArmy(unitType2, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
242 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
243 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
244 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
245 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
246 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
247 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
248 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
249
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
250 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
251 public void TestAddingTwoUnitsWithTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypePasses()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
252 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
253 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
254 AddUnitOfTypeToArmy(unitType3, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
255 AddUnitOfTypeToArmy(unitType3, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
256 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
257 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
258 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
259 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
260 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
261 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
262 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
263
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
264 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
265 public void TestAddingTwoUnitsWithTwoUnitTypeComboRequiredAndTwoUnitsOfOtherTypePasses()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
266 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
267 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
268 AddUnitOfTypeToArmy(unitType2, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
269 AddUnitOfTypeToArmy(unitType2, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
270 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
271 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
272 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
273 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
274 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
275 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
276 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
277
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
278 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
279 public void TestAddingThreeUnitsWithTwoUnitTypeComboRequiredAndOneUnitOfBothTypesFails()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
280 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
281 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
282 AddUnitOfTypeToArmy(unitType3, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
283 AddUnitOfTypeToArmy(unitType2, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
284 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
285 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
286 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
287 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
288 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
289 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
290 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 2 for 3)."));
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
291 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
292
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
293 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
294 public void TestAddingThreeUnitsWithTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypeFails()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
295 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
296 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
297 AddUnitOfTypeToArmy(unitType3, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
298 AddUnitOfTypeToArmy(unitType3, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
299 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
300 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
301 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
302 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
303 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
304 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
305 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 2 for 3)."));
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
306 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
307
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
308 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
309 public void TestAddingThreeUnitsWithTwoUnitTypeComboRequiredAndTwoUnitsOfOtherTypeFails()
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
310 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
311 Army army = new Army(mockRace, "Test", 1000);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
312 AddUnitOfTypeToArmy(unitType2, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
313 AddUnitOfTypeToArmy(unitType2, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
314 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
315 AddUnitOfTypeToArmy(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
316 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
317 req.AddUnitTypeRequirement(unitType2, unitType3);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
318 Unit unit = CreateUnitOfType(unitType1, army);
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
319 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
320 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 2 for 3)."));
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
321 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
322
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
323 [Test()]
198
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
324 public void TestAddingUnrelatedUnitWithNoUnitsAndThreeForEachTwoCombinedUnitTypesRequiredIsNA()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
325 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
326 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
327 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
328 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
329 Unit unit = CreateUnitOfType(unitType4, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
330 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.NotApplicable));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
331 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
332 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
333
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
334 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
335 public void TestAddingThirdUnitWithThreeForEachTwoUnitTypeComboRequiredAndUnitOfOneTypePasses()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
336 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
337 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
338 AddUnitOfTypeToArmy(unitType2, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
339 AddUnitsOfTypeToArmy(2, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
340 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
341 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
342 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
343 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
344 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
345 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
346
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
347 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
348 public void TestAddingThirdUnitWithThreeForEachTwoUnitTypeComboRequiredAndUnitOfOtherTypePasses()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
349 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
350 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
351 AddUnitOfTypeToArmy(unitType3, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
352 AddUnitsOfTypeToArmy(2, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
353 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
354 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
355 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
356 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
357 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
358 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
359
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
360 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
361 public void TestAddingSixthUnitWithThreeForEachTwoUnitTypeComboRequiredAndOneUnitOfBothTypesPasses()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
362 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
363 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
364 AddUnitOfTypeToArmy(unitType3, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
365 AddUnitOfTypeToArmy(unitType2, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
366 AddUnitsOfTypeToArmy(5, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
367 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
368 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
369 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
370 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
371 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
372 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
373
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
374 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
375 public void TestAddingSixthUnitWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypePasses()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
376 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
377 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
378 AddUnitsOfTypeToArmy(2, unitType3, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
379 AddUnitsOfTypeToArmy(5, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
380 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
381 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
382 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
383 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
384 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
385 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
386
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
387 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
388 public void TestAddingSixthUnitWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOtherTypePasses()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
389 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
390 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
391 AddUnitsOfTypeToArmy(2, unitType2, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
392 AddUnitsOfTypeToArmy(5, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
393 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
394 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
395 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
396 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
397 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
398 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
399
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
400 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
401 public void TestAddingSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndOneUnitOfBothTypesFails()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
402 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
403 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
404 AddUnitOfTypeToArmy(unitType3, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
405 AddUnitOfTypeToArmy(unitType2, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
406 AddUnitsOfTypeToArmy(6, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
407 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
408 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
409 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
410 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
411 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (would have 2 for 7)."));
198
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
412 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
413
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
414 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
415 public void TestAddingSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypeFails()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
416 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
417 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
418 AddUnitsOfTypeToArmy(2, unitType3, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
419 AddUnitsOfTypeToArmy(6, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
420 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
421 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
422 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
423 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
424 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (would have 2 for 7)."));
198
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
425 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
426
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
427 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
428 public void TestAddingSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOtherTypeFails()
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
429 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
430 Army army = new Army(mockRace, "Test", 1000);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
431 AddUnitsOfTypeToArmy(2, unitType2, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
432 AddUnitsOfTypeToArmy(6, unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
433 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
434 req.AddUnitTypeRequirement(3, unitType2, unitType3);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
435 Unit unit = CreateUnitOfType(unitType1, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
436 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
437 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (would have 2 for 7)."));
198
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
438 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
439
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
440 [Test()]
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
441 public void TestValidatingArmyWithNoUnitsAndOneUnitTypeRequiredIsNA()
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
442 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
443 Army army = new Army(mockRace, "Test", 1000);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
444 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
445 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
446 Assert.That(req.GetValidationMessage(army), Is.Empty);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
447 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
448
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
449 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
450 public void TestValidatingArmyWithOneUnitTypeRequiredAndOneUnitOfTypePasses()
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
451 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
452 Army army = new Army(mockRace, "Test", 1000);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
453 AddUnitOfTypeToArmy(unitType2, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
454 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
455 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
456 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
457 Assert.That(req.GetValidationMessage(army), Is.Empty);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
458 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
459
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
460 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
461 public void TestValidatingArmyWithOneUnitTypeRequiredAndNoUnitOfTypeFails()
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
462 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
463 Army army = new Army(mockRace, "Test", 1000);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
464 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
465 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
466 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
467 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."));
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
468 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
469
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
470 [Test()]
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
471 public void TestValidatingArmyWithTwoDifferentUnitTypesRequiredAndNoUnitOfOneTypeFails()
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
472 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
473 Army army = new Army(mockRace, "Test", 1000);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
474 AddUnitOfTypeToArmy(unitType2, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
475 AddUnitOfTypeToArmy(unitType1, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
476 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
477 req.AddUnitTypeRequirement(unitType2);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
478 req.AddUnitTypeRequirement(unitType3);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
479 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
480 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."));
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
481 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
482
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
483 [Test()]
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
484 public void TestValidatingArmyWithTwoUnitsAndOneUnitTypeRequiredAndOneUnitOfTypeFails()
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
485 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
486 Army army = new Army(mockRace, "Test", 1000);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
487 AddUnitOfTypeToArmy(unitType2, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
488 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
489 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
490 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
491 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
492 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."));
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
493 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
494
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
495 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
496 public void TestValidatingArmyWithTwoUnitsAndTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypePasses()
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
497 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
498 Army army = new Army(mockRace, "Test", 1000);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
499 AddUnitOfTypeToArmy(unitType2, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
500 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
501 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
502 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
503 req.AddUnitTypeRequirement(unitType2, 1, 2);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
504 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
505 Assert.That(req.GetValidationMessage(army), Is.Empty);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
506 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
507
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
508 [Test()]
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
509 public void TestValidatingArmyWithTwoUnitsWithTwoAllowedAndOneAllowedForDifferentTypesFails()
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
510 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
511 Army army = new Army(mockRace, "Test", 1000);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
512 AddUnitOfTypeToArmy(unitType2, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
513 AddUnitOfTypeToArmy(unitType3, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
514 AddUnitOfTypeToArmy(unitType1, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
515 AddUnitOfTypeToArmy(unitType1, army);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
516 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
517 req.AddUnitTypeRequirement(unitType2, 1, 2);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
518 req.AddUnitTypeRequirement(unitType3, 1, 1);
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
519 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
520 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."));
192
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
521 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
522
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
523 [Test()]
195
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
524 public void TestValidatingArmyWithTwoUnitsWithOneAllowedForTwoTypesFails()
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
525 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
526 Army army = new Army(mockRace, "Test", 1000);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
527 AddUnitOfTypeToArmy(unitType2, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
528 AddUnitOfTypeToArmy(unitType3, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
529 AddUnitOfTypeToArmy(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
530 AddUnitOfTypeToArmy(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
531 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
532 req.AddUnitTypeRequirement(unitType2, 1, 1);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
533 req.AddUnitTypeRequirement(unitType3, 1, 1);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
534 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
535 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."));
195
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
536 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
537
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
538 [Test()]
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
539 public void TestValidatingArmyWithTwoUnitsWithOneAllowedForTwoTypesFails_ShorthandMethod()
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
540 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
541 Army army = new Army(mockRace, "Test", 1000);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
542 AddUnitOfTypeToArmy(unitType2, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
543 AddUnitOfTypeToArmy(unitType3, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
544 AddUnitOfTypeToArmy(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
545 AddUnitOfTypeToArmy(unitType1, army);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
546 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2, unitType3);
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
547 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
548 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."));
195
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
549 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
550
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
551 [Test()]
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
552 public void TestValidatingArmyWithOneUnitWithThreeOfUnitTypeAllowedForTwoOfUnitTypeRequiredAndOneUnitOfTypeFails()
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
553 {
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
554 Army army = new Army(mockRace, "Test", 1000);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
555 AddUnitOfTypeToArmy(unitType2, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
556 AddUnitOfTypeToArmy(unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
557 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
558 req.AddUnitTypeRequirement(unitType2, 2, 3);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
559 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
560 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (have 1 for 1)."));
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
561 }
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
562
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
563 [Test()]
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
564 public void TestValidatingArmyWithTwoUnitsWithThreeOfUnitTypeAllowedForTwoOfUnitTypeRequiredAndOneUnitOfTypeFails()
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
565 {
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
566 Army army = new Army(mockRace, "Test", 1000);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
567 AddUnitOfTypeToArmy(unitType2, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
568 AddUnitsOfTypeToArmy(2, unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
569 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
570 req.AddUnitTypeRequirement(unitType2, 2, 3);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
571 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
572 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (have 1 for 2)."));
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
573 }
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
574
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
575 [Test()]
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
576 public void TestValidatingArmyWithFourUnitsWithThreeOfUnitTypeAllowedForTwoOfUnitTypeRequiredAndThreeUnitsOfTypeFails()
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
577 {
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
578 Army army = new Army(mockRace, "Test", 1000);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
579 AddUnitsOfTypeToArmy(3, unitType2, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
580 AddUnitsOfTypeToArmy(4, unitType1, army);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
581 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
582 req.AddUnitTypeRequirement(unitType2, 2, 3);
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
583 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
584 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (have 3 for 4)."));
202
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
585 }
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
586
49e50238c380 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
587 [Test()]
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
588 public void TestValidatingArmyWithThreeUnitsAndTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypeFails()
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
589 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
590 Army army = new Army(mockRace, "Test", 1000);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
591 AddUnitOfTypeToArmy(unitType2, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
592 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
593 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
594 AddUnitOfTypeToArmy(unitType1, army);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
595 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
596 req.AddUnitTypeRequirement(unitType2, 1, 2);
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
597 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
598 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 1 for 3)."));
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
599 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
600
199
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
601 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
602 public void TestValidatingArmyWithNoUnitsAndThreeForEachTwoCombinedUnitTypesRequiredIsNA()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
603 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
604 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
605 AddUnitOfTypeToArmy(unitType4, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
606 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
607 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
608 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
609 Assert.That(req.GetValidationMessage(army), Is.Empty);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
610 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
611
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
612 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
613 public void TestValidatingArmyWithThreeUnitsWithThreeForEachTwoUnitTypeComboRequiredAndUnitOfOneTypePasses()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
614 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
615 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
616 AddUnitOfTypeToArmy(unitType2, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
617 AddUnitsOfTypeToArmy(3, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
618 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
619 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
620 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
621 Assert.That(req.GetValidationMessage(army), Is.Empty);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
622 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
623
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
624 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
625 public void TestValidatingArmyWithThreeUnitsWithThreeForEachTwoUnitTypeComboRequiredAndUnitOfOtherTypePasses()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
626 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
627 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
628 AddUnitOfTypeToArmy(unitType3, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
629 AddUnitsOfTypeToArmy(3, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
630 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
631 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
632 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
633 Assert.That(req.GetValidationMessage(army), Is.Empty);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
634 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
635
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
636 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
637 public void TestValidatingArmyWithSixUnitsWithThreeForEachTwoUnitTypeComboRequiredAndOneUnitOfBothTypesPasses()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
638 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
639 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
640 AddUnitOfTypeToArmy(unitType3, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
641 AddUnitOfTypeToArmy(unitType2, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
642 AddUnitsOfTypeToArmy(6, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
643 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
644 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
645 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
646 Assert.That(req.GetValidationMessage(army), Is.Empty);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
647 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
648
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
649 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
650 public void TestValidatingArmyWithSixUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypePasses()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
651 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
652 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
653 AddUnitsOfTypeToArmy(2, unitType3, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
654 AddUnitsOfTypeToArmy(6, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
655 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
656 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
657 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
658 Assert.That(req.GetValidationMessage(army), Is.Empty);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
659 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
660
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
661 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
662 public void TestValidatingArmyWithSixUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOtherTypePasses()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
663 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
664 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
665 AddUnitsOfTypeToArmy(2, unitType2, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
666 AddUnitsOfTypeToArmy(6, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
667 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
668 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
669 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
670 Assert.That(req.GetValidationMessage(army), Is.Empty);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
671 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
672
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
673 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
674 public void TestValidatingArmyWithSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndOneUnitOfBothTypesFails()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
675 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
676 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
677 AddUnitOfTypeToArmy(unitType3, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
678 AddUnitOfTypeToArmy(unitType2, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
679 AddUnitsOfTypeToArmy(7, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
680 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
681 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
682 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
683 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (have 2 for 7)."));
199
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
684 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
685
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
686 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
687 public void TestValidatingArmyWithSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypeFails()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
688 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
689 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
690 AddUnitsOfTypeToArmy(2, unitType3, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
691 AddUnitsOfTypeToArmy(7, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
692 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
693 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
694 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
695 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (have 2 for 7)."));
199
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
696 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
697
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
698 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
699 public void TestValidatingArmyWithSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOtherTypeFails()
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
700 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
701 Army army = new Army(mockRace, "Test", 1000);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
702 AddUnitsOfTypeToArmy(2, unitType2, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
703 AddUnitsOfTypeToArmy(7, unitType1, army);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
704 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
705 req.AddUnitTypeRequirement(3, unitType2, unitType3);
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
706 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
707 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (have 2 for 7)."));
199
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
708 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
709
198
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
710 private static void AddUnitsOfTypeToArmy(int count, UnitType unitType, Army army)
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
711 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
712 for (int i = 0; i < count; i++)
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
713 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
714 AddUnitOfTypeToArmy(unitType, army);
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
715 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
716 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
717
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
718 private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
719 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
720 army.AddUnit(CreateUnitOfType(unitType, army));
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
721 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
722
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
723 private static Unit CreateUnitOfType(UnitType unitType, Army army)
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
724 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
725 return new Unit(unitType, army.GetCategory(unitType.MainCategory));
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
726 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
727
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
728 public override RequiresNUnitsForMUnitsRequirement GetObject()
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
729 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
730 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
731 req.AddUnitTypeRequirement(unitType1, 2, 3);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
732 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
733 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
734
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
735 public override RequiresNUnitsForMUnitsRequirement GetSameObject()
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
736 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
737 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
738 req.AddUnitTypeRequirement(unitType1, 2, 3);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
739 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
740 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
741
207
27f163bf884a Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 202
diff changeset
742 public override RequiresNUnitsForMUnitsRequirement GetDifferentObject()
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
743 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
744 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
745 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
746 GameSystem gameSystem = new GameSystem("system", "system", factory);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
747 Race race = new Race("race", "race", gameSystem, factory);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
748 req.AddUnitTypeRequirement(new UnitType("id2", "Type 2", race), 2, 3);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
749 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
750 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
751 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
752 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
753