annotate API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs @ 214:1674a499168e

Re #379: * Make all tests test both Unit and UnitType by modifying abstract class's helper methods * Re-implement UnitRequiresAtLeastNUnitsRequirementTest tests (adding and validation) * Remove unused tests from Requires... TODO: Re-implement equality testing
author IBBoard <dev@ibboard.co.uk>
date Sun, 26 Feb 2012 20:18:45 +0000
parents 325943cb1db0
children 9bf34e88da89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitRequiresNUnitsForMUnitsRequirementTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
c323770e61c2 Re #379: Fix validation of requirements to check for unit
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.
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects.Requirement
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 [TestFixture()]
212
325943cb1db0 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 211
diff changeset
12 public class UnitRequiresNUnitsForMUnitsRequirementTests : AbstractUnitRequirementTest<UnitType>
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 private MockRace mockRace;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 private UnitType unitType1;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 private UnitType unitType2;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 private UnitType unitType3;
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 [TestFixtureSetUp()]
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 public void SetupRace()
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 mockRace = new MockRace();
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 unitType1 = new MockUnitType("type1", "Unit Type 1");
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 mockRace.AddUnitType(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 unitType2 = new MockUnitType("type2", "Unit Type 2");
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 mockRace.AddUnitType(unitType2);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 unitType3 = new MockUnitType("type3", "Unit Type 3");
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 mockRace.AddUnitType(unitType3);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 [Test()]
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
32 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredFails()
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
33 {
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
34 Army army = new Army(mockRace, "Test", 1000);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
35 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
36 req.AddUnitTypeRequirement(unitType2);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
37 Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).");
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
38 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
39
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
40 [Test()]
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
41 public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredPasses()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 AddUnitOfTypeToArmy(unitType2, army);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 req.AddUnitTypeRequirement(unitType2);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
47 Assert_That__PassesAdding(req, unitType1, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
48 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
49
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
50 [Test()]
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
51 public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredPassesWhenAddingRequiredUnitType()
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
52 {
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
53 Army army = new Army(mockRace, "Test", 1000);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
54 AddUnitOfTypeToArmy(unitType1, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
55 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
56 req.AddUnitTypeRequirement(unitType2);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
57 Assert_That__PassesAdding(req, unitType2, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 [Test()]
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 public void TestAddingUnitTypeSetsLimit()
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 AddUnitOfTypeToArmy(unitType2, army);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 req.AddUnitTypeRequirement(unitType2, 1);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
67 Assert_That__PassesAdding(req, unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 [Test()]
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 public void TestAddingUnitTypeSetsLimitForFailure()
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 Army army = new Army(mockRace, "Test", 1000);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
74 AddUnitOfTypeToArmy(unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 AddUnitOfTypeToArmy(unitType2, army);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 req.AddUnitTypeRequirement(unitType2, 1);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
78 Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).");
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 [Test()]
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
82 public void TestAddingUnitTriggersPass()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 req.AddUnitTypeRequirement(unitType2, 1);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
87 Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).");
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 AddUnitOfTypeToArmy(unitType2, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
89 Assert_That__PassesAdding(req, unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 [Test()]
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
93 public void TestAddingLimitedUnitTriggersFailure()
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
94 {
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
95 Army army = new Army(mockRace, "Test", 1000);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
96 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
97 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
98 req.AddUnitTypeRequirement(unitType2);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
99 Assert_That__PassesAdding(req, unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
100 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
101 Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).");
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
102 }
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
103
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
104 [Test()]
209
fc9a90d29ae0 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 208
diff changeset
105 public void TestAddingUnitTypeDefaultsToOne()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 req.AddUnitTypeRequirement(unitType2);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
110 Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).");
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 AddUnitOfTypeToArmy(unitType2, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
112 Assert_That__PassesAdding(req, unitType1, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 [Test]
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
116 public void TestRequirementNotApplicableWhenCheckingAddForNonLimitedUnits()
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
117 {
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
118 Army army = new Army(mockRace, "Test", 1000);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
119 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
120 req.AddUnitTypeRequirement(unitType2);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
121 Assert_That__AddingNotApplicable(req, unitType3, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
122 Assert_That__AddingNotApplicable(req, unitType2, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
123 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
124
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
125 [Test]
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
126 public void TestRequirementNotApplicableAfterAddingLimitedUnit()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 req.AddUnitTypeRequirement(unitType2);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
131 Assert_That__AddingNotApplicable(req, unitType3, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
132 AddUnitOfTypeToArmy(unitType1, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
133 Assert_That__AddingNotApplicable(req, unitType3, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 [Test]
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
137 public void TestRequirementNotApplicableBecomesPassAfterAddingLimitedUnit()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 req.AddUnitTypeRequirement(unitType2);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
142 Assert_That__AddingNotApplicable(req, unitType2, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
143 AddUnitOfTypeToArmy(unitType1, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
144 Assert_That__PassesAdding(req, unitType2, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
145 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
146
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
147 [Test]
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
148 public void TestRequirementNotApplicableBecomesFailAfterAddingLimitedUnit()
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
149 {
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
150 Army army = new Army(mockRace, "Test", 1000);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
151 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
152 req.AddUnitTypeRequirement(unitType2, 2, 1);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
153 Assert_That__AddingNotApplicable(req, unitType2, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
154 AddUnitOfTypeToArmy(unitType1, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
155 Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 2 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 1).");
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
156 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
158 [Test]
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
159 public void TestRequirementFailsWhenLimitedUnitsChange()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 AddUnitOfTypeToArmy(unitType1, army);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 req.AddUnitTypeRequirement(unitType2);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
165 Assert_That__PassesAdding(req, unitType2, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
166 AddUnitOfTypeToArmy(unitType1, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
167 Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).");
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
168 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
169
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
170 [Test]
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
171 public void TestValidationNotApplicableWithNoLimitedUnit()
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
172 {
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
173 Army army = new Army(mockRace, "Test", 1000);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
174 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
175 req.AddUnitTypeRequirement(unitType2);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
176 Assert_That__NotApplicable(req, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
177 AddUnitOfTypeToArmy(unitType3, army);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
178 Assert_That__NotApplicable(req, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
179 AddUnitOfTypeToArmy(unitType2, army);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
180 Assert_That__NotApplicable(req, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
181 }
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
182
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
183 [Test()]
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
184 public void TestValidatingWithNoUnitsAndOneUnitTypeRequiredFails()
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
185 {
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
186 Army army = new Army(mockRace, "Test", 1000);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
187 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
188 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
189 req.AddUnitTypeRequirement(unitType2);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
190 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1).");
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
191 }
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
192
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
193 [Test()]
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
194 public void TestValidatingUnitWithOneUnitAndOneUnitTypeRequiredPasses()
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
195 {
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
196 Army army = new Army(mockRace, "Test", 1000);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
197 AddUnitOfTypeToArmy(unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
198 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
199 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
200 req.AddUnitTypeRequirement(unitType2);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
201 Assert_That__ValidationPasses(req, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
202 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
203
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
204 [Test()]
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
205 public void TestValidatingUnitTypeSetsLimit()
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
206 {
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
207 Army army = new Army(mockRace, "Test", 1000);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
208 AddUnitOfTypeToArmy(unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
209 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
210 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
211 req.AddUnitTypeRequirement(unitType2, 1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
212 Assert_That__ValidationPasses(req, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
213 }
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
214
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
215 [Test()]
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
216 public void TestValidatingUnitTypeSetsLimitForFailure()
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
217 {
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
218 Army army = new Army(mockRace, "Test", 1000);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
219 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
220 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
221 AddUnitOfTypeToArmy(unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
222 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
223 req.AddUnitTypeRequirement(unitType2, 1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
224 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).");
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
225 }
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
226
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
227 [Test()]
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
228 public void TestAddingUnitTriggersValidationPass()
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
229 {
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
230 Army army = new Army(mockRace, "Test", 1000);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
231 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
232 req.AddUnitTypeRequirement(unitType2, 1);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
233 AddUnitOfTypeToArmy(unitType1, army);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
234 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1).");
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
235 AddUnitOfTypeToArmy(unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
236 Assert_That__ValidationPasses(req, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
237 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
238
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
239 [Test()]
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
240 public void TestAddingLimitedUnitTriggersValidationFailure()
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
241 {
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
242 Army army = new Army(mockRace, "Test", 1000);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
243 AddUnitOfTypeToArmy(unitType1, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
244 AddUnitOfTypeToArmy(unitType2, army);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
245 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
246 req.AddUnitTypeRequirement(unitType2);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
247 Assert_That__ValidationPasses(req, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
248 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
249 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).");
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
250 }
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
251
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
252 [Test()]
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
253 public void TestValidatingUnitTypeDefaultsToOne()
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
254 {
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
255 Army army = new Army(mockRace, "Test", 1000);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
256 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
257 req.AddUnitTypeRequirement(unitType2);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
258 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
259 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1).");
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
260 AddUnitOfTypeToArmy(unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
261 Assert_That__ValidationPasses(req, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
262 }
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
263
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
264 [Test]
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
265 public void TestValidationRequirementNotApplicableWhenCheckingForNonLimitedUnits()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
266 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
267 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
268 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
269 req.AddUnitTypeRequirement(unitType2);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
270 AddUnitOfTypeToArmy(unitType3, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
271 Assert_That__NotApplicable(req, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
272 AddUnitOfTypeToArmy(unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
273 Assert_That__NotApplicable(req, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
274 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
275
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
276 [Test]
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
277 public void TestValidationNotApplicableBecomesPassAfterAddingLimitedUnit()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
278 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
279 Army army = new Army(mockRace, "Test", 1000);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
280 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
281 req.AddUnitTypeRequirement(unitType2);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
282 AddUnitOfTypeToArmy(unitType2, army);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
283 Assert_That__NotApplicable(req, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
284 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
285 Assert_That__ValidationPasses(req, army);
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
286 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
287
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
288 [Test]
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
289 public void TestValidationRequirementNotApplicableBecomesFailAfterAddingLimitedUnit()
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
290 {
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
291 Army army = new Army(mockRace, "Test", 1000);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
292 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
293 req.AddUnitTypeRequirement(unitType2, 2, 1);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
294 AddUnitOfTypeToArmy(unitType2, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
295 Assert_That__NotApplicable(req, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
296 AddUnitOfTypeToArmy(unitType1, army);
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
297 Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 1).");
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
298 }
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
299
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
300 [Test]
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
301 public void TestValidationRequirementFailsWhenLimitedUnitsChange()
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
302 {
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
303 Army army = new Army(mockRace, "Test", 1000);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
304 AddUnitOfTypeToArmy(unitType1, army);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
305 AddUnitOfTypeToArmy(unitType2, army);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
306 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
307 req.AddUnitTypeRequirement(unitType2);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
308 Assert_That__ValidationPasses(req, army);
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
309 AddUnitOfTypeToArmy(unitType1, army);
211
bc782a0d47bf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 210
diff changeset
310 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).");
210
649759343da5 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 209
diff changeset
311 }
208
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
312 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
313 }
c323770e61c2 Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
314