annotate API/Objects/Requirement/RequiresNUnitsForMUnitsRequirementTest.cs @ 195:8e95ccb8e9d5

Re #350: Add requirement to allow N of unit for specific other units * Add tests for multiple failures
author IBBoard <dev@ibboard.co.uk>
date Sat, 03 Dec 2011 20:09:25 +0000
parents f25cb069f700
children aa921248ffbf
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;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 [TestFixtureSetUp()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 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
24 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 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
26 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
27 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
28 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
29 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
30 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
31 mockRace.AddUnitType(unitType3);
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 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
36 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 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
38 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
39 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
40 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
41 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
42 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 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
46 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 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
48 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
49 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
50 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
51 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
52 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
53 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 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
57 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 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
59 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
60 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
61 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
62 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
63 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 [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
66 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
67 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
77
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
78 [Test()]
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 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
80 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 [Test()]
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 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
92 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 }
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
102
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
103 [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
104 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
105 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
117
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
118 [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
119 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
120 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
132
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
133 [Test()]
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
134 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
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 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
145
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
146 [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
147 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
148 {
eea440e5891b Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 188
diff changeset
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159
190
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
160 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
161 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
162 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
163 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
164 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
165 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
166 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
167 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
168
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
169 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
170 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
171 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
172 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
173 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
174 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
175 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
176 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
177 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
178 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
179
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
180 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
181 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
182 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
183 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
184 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
185 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
186 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
187 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
188 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
189
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
190 [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
191 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
192 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
202
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
203 [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
204 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
205 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
214
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
215 [Test()]
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
216 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
217 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
227
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
228 [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
229 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
230 {
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 }
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
242
f25cb069f700 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 191
diff changeset
243 [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
244 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
245 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
257
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
258 [Test()]
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
259 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
260 {
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269 }
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
270
8e95ccb8e9d5 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 192
diff changeset
271 [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
272 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
273 {
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 }
702a0957f9e4 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 189
diff changeset
284
188
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
285 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
286 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
287 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
288 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
289
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
290 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
291 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
292 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
293 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
294
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
295 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
296 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
297 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
298 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
299 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
300 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
301
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
302 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
303 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
304 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
305 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
306 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
307 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
308
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
309 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
310 {
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
311 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
312 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
313 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
314 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
315 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
316 return req;
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
317 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
318 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
319 }
0762766bd3f2 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
320