annotate API/Objects/Requirement/RequiresNUnitsForMUnitsRequirementTest.cs @ 199:925c37fa4feb

Re #350: Add requirement to allow N of unit for specific other units * Add unit tests for validating army, based on adding unit tests
author IBBoard <dev@ibboard.co.uk>
date Tue, 20 Dec 2011 20:34:48 +0000
parents 6a54d1787fbe
children 49e50238c380
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));
191
2b19d6f18f3a Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 190
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));
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
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)."));
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));
191
2b19d6f18f3a Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 190
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));
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
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)."));
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));
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
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)."));
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));
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
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)."));
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));
191
2b19d6f18f3a Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 190
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()]
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
164 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
165 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
166 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
167 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
168 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
169 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
170 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
171 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
172 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
173
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
174 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
175 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
176 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
185
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
186 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
187 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
188 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
197
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
198 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
199 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
200 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
201 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
202 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
203 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
204 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
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(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
208 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
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 TestAddingTwoUnitsWithTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypePasses()
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(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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
225
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
226 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
227 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
228 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
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
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
240 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
241 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
242 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
252 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)."));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
253 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
254
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
255 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
256 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
257 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
267 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)."));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
268 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
269
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
270 [Test()]
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
271 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
272 {
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
273 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
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
282 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)."));
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
283 }
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
284
aa921248ffbf Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 195
diff changeset
285 [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
286 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
287 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
288 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
289 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
290 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
291 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
292 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
293 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
294 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
295
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
296 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
297 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
298 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
299 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
300 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
301 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
302 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
303 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
304 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
305 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
306 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
307 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
308
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
309 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
310 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
311 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
312 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
313 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
314 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
315 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
316 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
317 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
318 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
319 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
320 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
321
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
322 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
323 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
324 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
325 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
326 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
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
335
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
336 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
337 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
338 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
348
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
349 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
350 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
351 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
361
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
362 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
363 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
364 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
365 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
366 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
367 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
368 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
369 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
370 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
371 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
372 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
373 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)."));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
374 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
375
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
376 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
377 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
378 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
379 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
380 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
381 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
382 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
383 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
384 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
385 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
386 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)."));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
387 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
388
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
389 [Test()]
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
390 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
391 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
392 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
393 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
394 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
395 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
396 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
397 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
398 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
399 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)."));
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
400 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
401
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
402 [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
403 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
404 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
405 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
406 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
407 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
408 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
409 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
410
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
411 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
412 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
413 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
414 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
415 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
416 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
417 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
418 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
419 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
420 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
421
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
422 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
423 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
424 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
425 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
426 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
427 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
428 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
429 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 0 for 1)."));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
430 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
431
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
432 [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
433 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
434 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
435 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
436 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
437 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
438 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
439 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
440 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
441 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
442 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (have 0 for 1)."));
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
443 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
444
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
445 [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
446 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
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 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
449 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
450 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
451 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
452 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
453 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
454 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 1 for 2)."));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
455 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
456
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
457 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
458 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
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 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
461 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
462 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
463 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
464 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
465 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
466 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
467 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
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 TestValidatingArmyWithTwoUnitsWithTwoAllowedAndOneAllowedForDifferentTypesFails()
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(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
476 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
477 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
478 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
479 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
480 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
481 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
482 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (have 1 for 2)."));
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
483 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
484
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
485 [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
486 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
487 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
488 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
489 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
490 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
491 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
492 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
493 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
494 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
495 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
496 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
497 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)."));
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
498 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
499
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
500 [Test()]
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
501 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
502 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
503 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
504 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
505 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
506 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
507 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
508 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
509 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
510 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)."));
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
511 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
512
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
513 [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
514 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
515 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
516 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
517 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
518 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
519 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
520 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
521 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
522 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
523 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
524 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 2 " + unitType1.Name + " (have 1 for 3)."));
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
525 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
526
199
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
527 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
528 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
529 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
530 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
531 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
532 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
533 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
534 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
535 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
536 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
537
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
538 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
539 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
540 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
541 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
542 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
543 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
544 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
545 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
546 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
547 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
548 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
549
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
550 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
551 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
552 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
553 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
554 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
555 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
556 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
557 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
558 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
559 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
560 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
561
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
562 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
563 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
564 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
565 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
566 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
567 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
568 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
569 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
570 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
571 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
572 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
573 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
574
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
575 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
576 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
577 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
578 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
579 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
580 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
581 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
582 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
583 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
584 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
585 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
586
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
587 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
588 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
589 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
590 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
591 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
592 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
593 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
594 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
595 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
596 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
597 }
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
598
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
599 [Test()]
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
600 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
601 {
925c37fa4feb Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
602 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
603 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
604 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
605 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
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.Failed));
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.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (have 2 for 7)."));
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 TestValidatingArmyWithSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOneTypeFails()
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 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
617 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
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.Failed));
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.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (have 2 for 7)."));
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 TestValidatingArmyWithSevenUnitsWithThreeForEachTwoUnitTypeComboRequiredAndTwoUnitsOfOtherTypeFails()
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 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
629 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
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.Failed));
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.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (have 2 for 7)."));
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
198
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
636 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
637 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
638 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
639 {
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
640 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
641 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
642 }
6a54d1787fbe Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 197
diff changeset
643
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
644 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
645 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
646 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
647 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
648
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
649 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
650 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
651 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
652 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
653
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
654 public override RequiresNUnitsForMUnitsRequirement GetObject()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
655 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
656 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
657 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
658 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
659 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
660
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
661 public override RequiresNUnitsForMUnitsRequirement GetSameObject()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
662 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
663 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
664 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
665 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
666 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
667
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
668 public override RequiresNUnitsForMUnitsRequirement GetDifferentObject()
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
669 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
670 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
671 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
672 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
673 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
674 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
675 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
676 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
677 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
678 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
679