changeset 210:649759343da5

Re #379: Fix validation of requirements to check for unit * Tidy up tests to reduce replication and fix copy-and-paste inconsistencies
author IBBoard <dev@ibboard.co.uk>
date Sat, 25 Feb 2012 16:36:20 +0000
parents fc9a90d29ae0
children bc782a0d47bf
files API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs
diffstat 1 files changed, 179 insertions(+), 76 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Wed Feb 22 21:00:01 2012 +0000
     1.2 +++ b/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Sat Feb 25 16:36:20 2012 +0000
     1.3 @@ -29,43 +29,64 @@
     1.4  		}
     1.5  
     1.6  		[Test()]
     1.7 -		public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
     1.8 +		public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequiredFails()
     1.9  		{
    1.10  			Army army = new Army(mockRace, "Test", 1000);
    1.11  			Unit unit = CreateUnitOfType(unitType1, army);
    1.12  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.13  			req.AddUnitTypeRequirement(unitType2);
    1.14 -			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
    1.15 +			Assert_That__FailsAdding(req, unit, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).");
    1.16  		}
    1.17  
    1.18  		[Test()]
    1.19 -		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
    1.20 +		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredFails()
    1.21 +		{
    1.22 +			Army army = new Army(mockRace, "Test", 1000);
    1.23 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.24 +			req.AddUnitTypeRequirement(unitType2);
    1.25 +			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).");
    1.26 +		}
    1.27 +
    1.28 +		[Test()]
    1.29 +		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequiredPasses()
    1.30  		{
    1.31  			Army army = new Army(mockRace, "Test", 1000);
    1.32  			AddUnitOfTypeToArmy(unitType2, army);
    1.33  			Unit unit = CreateUnitOfType(unitType1, army);
    1.34  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.35  			req.AddUnitTypeRequirement(unitType2);
    1.36 -			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
    1.37 +			Assert_That__PassesAdding(req, unit, army);
    1.38  		}
    1.39  
    1.40  		[Test()]
    1.41 -		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
    1.42 -		{
    1.43 -			Army army = new Army(mockRace, "Test", 1000);
    1.44 -			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.45 -			req.AddUnitTypeRequirement(unitType2);
    1.46 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.47 -		}
    1.48 -
    1.49 -		[Test()]
    1.50 -		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
    1.51 +		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredPasses()
    1.52  		{
    1.53  			Army army = new Army(mockRace, "Test", 1000);
    1.54  			AddUnitOfTypeToArmy(unitType2, army);
    1.55  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.56  			req.AddUnitTypeRequirement(unitType2);
    1.57 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.58 +			Assert_That__PassesAdding(req, unitType1, army);
    1.59 +		}
    1.60 +
    1.61 +		[Test()]
    1.62 +		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequiredPassesWhenAddingRequiredUnit()
    1.63 +		{
    1.64 +			Army army = new Army(mockRace, "Test", 1000);
    1.65 +			AddUnitOfTypeToArmy(unitType1, army);
    1.66 +			Unit unit = CreateUnitOfType(unitType2, army);
    1.67 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.68 +			req.AddUnitTypeRequirement(unitType2);
    1.69 +			Assert_That__PassesAdding(req, unit, army);
    1.70 +		}
    1.71 +
    1.72 +		[Test()]
    1.73 +		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredPassesWhenAddingRequiredUnitType()
    1.74 +		{
    1.75 +			Army army = new Army(mockRace, "Test", 1000);
    1.76 +			AddUnitOfTypeToArmy(unitType1, army);
    1.77 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.78 +			req.AddUnitTypeRequirement(unitType2);
    1.79 +			Assert_That__PassesAdding(req, unitType2, army);
    1.80  		}
    1.81  
    1.82  		[Test()]
    1.83 @@ -75,64 +96,85 @@
    1.84  			AddUnitOfTypeToArmy(unitType2, army);
    1.85  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.86  			req.AddUnitTypeRequirement(unitType2, 1);
    1.87 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.88 +			Assert_That__PassesAdding(req, unitType1, army);
    1.89  		}
    1.90  
    1.91  		[Test()]
    1.92  		public void TestAddingUnitTypeSetsLimitForFailure()
    1.93  		{
    1.94  			Army army = new Army(mockRace, "Test", 1000);
    1.95 -			AddUnitOfTypeToArmy(unitType2, army);
    1.96 +			AddUnitOfTypeToArmy(unitType1, army);
    1.97  			AddUnitOfTypeToArmy(unitType2, army);
    1.98  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.99  			req.AddUnitTypeRequirement(unitType2, 1);
   1.100 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.101 +			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).");
   1.102  		}
   1.103  
   1.104  		[Test()]
   1.105 -		public void TestAddingUnitTriggersFailure()
   1.106 +		public void TestAddingUnitTriggersPass()
   1.107  		{
   1.108  			Army army = new Army(mockRace, "Test", 1000);
   1.109 -			AddUnitOfTypeToArmy(unitType1, army);
   1.110  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.111  			req.AddUnitTypeRequirement(unitType2, 1);
   1.112 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.113 +			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).");
   1.114  			AddUnitOfTypeToArmy(unitType2, army);
   1.115 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.116 +			Assert_That__PassesAdding(req, unitType1, army);
   1.117  		}
   1.118  
   1.119  		[Test()]
   1.120  		public void TestAddingUnitTypeDefaultsToOne()
   1.121  		{
   1.122  			Army army = new Army(mockRace, "Test", 1000);
   1.123 -			AddUnitOfTypeToArmy(unitType1, army);
   1.124  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.125  			req.AddUnitTypeRequirement(unitType2);
   1.126 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.127 +			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).");
   1.128  			AddUnitOfTypeToArmy(unitType2, army);
   1.129 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.130 +			Assert_That__PassesAdding(req, unitType1, army);
   1.131  		}
   1.132  
   1.133  		[Test]
   1.134 -		public void TestRequirementNotApplicableWhenLimitedUnitNotIncluded()
   1.135 +		public void TestRequirementNotApplicableWhenCheckingAddForNonLimitedUnits()
   1.136  		{
   1.137  			Army army = new Army(mockRace, "Test", 1000);
   1.138  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.139  			req.AddUnitTypeRequirement(unitType2);
   1.140 -			Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable));
   1.141 -			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.NotApplicable));
   1.142 +			Assert_That__AddingNotApplicable(req, unitType3, army);
   1.143 +			Assert_That__AddingNotApplicable(req, CreateUnitOfType(unitType3, army), army);
   1.144 +			Assert_That__AddingNotApplicable(req, unitType2, army);
   1.145 +			Assert_That__AddingNotApplicable(req, CreateUnitOfType(unitType2, army), army);
   1.146  		}
   1.147  
   1.148  		[Test]
   1.149 -		public void TestRequirementBecomesInvalidWhenProhibitedUnitsChange()
   1.150 +		public void TestRequirementNotApplicableAfterAddingLimitedUnit()
   1.151  		{
   1.152  			Army army = new Army(mockRace, "Test", 1000);
   1.153 -			AddUnitOfTypeToArmy(unitType1, army);
   1.154  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.155  			req.AddUnitTypeRequirement(unitType2);
   1.156 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   1.157 -			AddUnitOfTypeToArmy(unitType2, army);
   1.158 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   1.159 +			Assert_That__AddingNotApplicable(req, unitType3, army);
   1.160 +			AddUnitOfTypeToArmy(unitType1, army);
   1.161 +			Assert_That__AddingNotApplicable(req, unitType3, army);
   1.162 +		}
   1.163 +
   1.164 +		[Test]
   1.165 +		public void TestRequirementNotApplicableBecomesPassAfterAddingLimitedUnit()
   1.166 +		{
   1.167 +			Army army = new Army(mockRace, "Test", 1000);
   1.168 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.169 +			req.AddUnitTypeRequirement(unitType2);
   1.170 +			Assert_That__AddingNotApplicable(req, unitType2, army);
   1.171 +			AddUnitOfTypeToArmy(unitType1, army);
   1.172 +			Assert_That__PassesAdding(req, unitType2, army);
   1.173 +		}
   1.174 +
   1.175 +		[Test]
   1.176 +		public void TestRequirementNotApplicableBecomesFailAfterAddingLimitedUnit()
   1.177 +		{
   1.178 +			Army army = new Army(mockRace, "Test", 1000);
   1.179 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.180 +			req.AddUnitTypeRequirement(unitType2, 2, 1);
   1.181 +			Assert_That__AddingNotApplicable(req, unitType2, army);
   1.182 +			AddUnitOfTypeToArmy(unitType1, army);
   1.183 +			Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 2 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 1).");
   1.184  		}
   1.185  
   1.186  		[Test()]
   1.187 @@ -142,11 +184,60 @@
   1.188  			AddUnitOfTypeToArmy(unitType1, army);
   1.189  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.190  			req.AddUnitTypeRequirement(unitType2);
   1.191 -			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
   1.192 +			Assert_That__PassesAdding(req, unitType2, army);
   1.193 +			AddUnitOfTypeToArmy(unitType1, army);
   1.194 +			Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).");
   1.195  		}
   1.196  
   1.197  		[Test]
   1.198 -		public void TestValidationMessageIsBlankForPass()
   1.199 +		public void TestRequirementFailsWhenLimitedUnitsChange()
   1.200 +		{
   1.201 +			Army army = new Army(mockRace, "Test", 1000);
   1.202 +			AddUnitOfTypeToArmy(unitType1, army);
   1.203 +			AddUnitOfTypeToArmy(unitType2, army);
   1.204 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.205 +			req.AddUnitTypeRequirement(unitType2);
   1.206 +			Assert_That__PassesAdding(req, unitType2, army);
   1.207 +			AddUnitOfTypeToArmy(unitType1, army);
   1.208 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   1.209 +		}
   1.210 +
   1.211 +		[Test]
   1.212 +		public void TestValidationNotApplicableWithNoLimitedUnit()
   1.213 +		{
   1.214 +			Army army = new Army(mockRace, "Test", 1000);
   1.215 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.216 +			req.AddUnitTypeRequirement(unitType2);
   1.217 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
   1.218 +			AddUnitOfTypeToArmy(unitType3, army);
   1.219 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
   1.220 +			AddUnitOfTypeToArmy(unitType2, army);
   1.221 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
   1.222 +		}
   1.223 +
   1.224 +		[Test()]
   1.225 +		public void TestValidationWithNoUnitsAndOneUnitTypeRequiredFails()
   1.226 +		{
   1.227 +			Army army = new Army(mockRace, "Test", 1000);
   1.228 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.229 +			req.AddUnitTypeRequirement(unitType2);
   1.230 +			AddUnitOfTypeToArmy(unitType1, army);
   1.231 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   1.232 +		}
   1.233 +
   1.234 +		[Test()]
   1.235 +		public void TestValidationWithOneUnitAndOneUnitTypeRequiredPasses()
   1.236 +		{
   1.237 +			Army army = new Army(mockRace, "Test", 1000);
   1.238 +			AddUnitOfTypeToArmy(unitType1, army);
   1.239 +			AddUnitOfTypeToArmy(unitType2, army);
   1.240 +			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.241 +			req.AddUnitTypeRequirement(unitType2);
   1.242 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   1.243 +		}
   1.244 +
   1.245 +		[Test]
   1.246 +		public void TestValidationMessageIsBlankForNotApplicable()
   1.247  		{
   1.248  			Army army = new Army(mockRace, "Test", 1000);
   1.249  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.250 @@ -155,14 +246,13 @@
   1.251  		}
   1.252  
   1.253  		[Test]
   1.254 -		public void TestValidationMessageIsCorrectForFailWithOneUnitProhibited()
   1.255 +		public void TestValidationMessageIsCorrectForFailWithOneUnitRequired()
   1.256  		{
   1.257  			Army army = new Army(mockRace, "Test", 1000);
   1.258  			AddUnitOfTypeToArmy(unitType1, army);
   1.259 -			AddUnitOfTypeToArmy(unitType2, army);
   1.260  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.261  			req.AddUnitTypeRequirement(unitType2);
   1.262 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (have 1)."));
   1.263 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."));
   1.264  		}
   1.265  
   1.266  		[Test]
   1.267 @@ -170,16 +260,16 @@
   1.268  		{
   1.269  			Army army = new Army(mockRace, "Test", 1000);
   1.270  			AddUnitOfTypeToArmy(unitType1, army);
   1.271 -			AddUnitOfTypeToArmy(unitType2, army);
   1.272 -			AddUnitOfTypeToArmy(unitType2, army);
   1.273 +			AddUnitOfTypeToArmy(unitType1, army);
   1.274 +			AddUnitOfTypeToArmy(unitType1, army);
   1.275  			AddUnitOfTypeToArmy(unitType2, army);
   1.276  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.277  			req.AddUnitTypeRequirement(unitType2, 2);
   1.278 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every " + unitType1.Name + " (have 3)."));
   1.279 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 1 for 3)."));
   1.280  		}
   1.281  
   1.282  		[Test]
   1.283 -		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibited()
   1.284 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequiredAndOneOfOneUnit()
   1.285  		{
   1.286  			Army army = new Army(mockRace, "Test", 1000);
   1.287  			AddUnitOfTypeToArmy(unitType1, army);
   1.288 @@ -191,7 +281,7 @@
   1.289  		}
   1.290  
   1.291  		[Test]
   1.292 -		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibitedAndOtherUnitInArmy()
   1.293 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequiredAndOneOfOtherUnitInArmy()
   1.294  		{
   1.295  			Army army = new Army(mockRace, "Test", 1000);
   1.296  			AddUnitOfTypeToArmy(unitType1, army);
   1.297 @@ -203,35 +293,14 @@
   1.298  		}
   1.299  
   1.300  		[Test]
   1.301 -		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibitedAndBothUnitsInArmy()
   1.302 +		public void TestValidationMessageIsCorrectForFailWithTwoRequiredUnitsAndNeitherInArmy()
   1.303  		{
   1.304  			Army army = new Army(mockRace, "Test", 1000);
   1.305  			AddUnitOfTypeToArmy(unitType1, army);
   1.306 -			AddUnitOfTypeToArmy(unitType2, army);
   1.307 -			AddUnitOfTypeToArmy(unitType3, army);
   1.308 -			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.309 -			req.AddUnitTypeRequirement(unitType2);
   1.310 -			req.AddUnitTypeRequirement(unitType3);
   1.311 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (have 1); 0 × " + unitType3.Name + " for every " + unitType1.Name + " (have 1)."));
   1.312 -		}
   1.313 -
   1.314 -		[Test]
   1.315 -		public void TestAllowsAddMessageIsBlankForPass()
   1.316 -		{
   1.317 -			Army army = new Army(mockRace, "Test", 1000);
   1.318 -			AddUnitOfTypeToArmy(unitType1, army);
   1.319 -			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.320 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.Empty);
   1.321 -		}
   1.322 -
   1.323 -		[Test]
   1.324 -		public void TestAllowsAddMessageIsCorrectForFailWithOneUnitProhibited()
   1.325 -		{
   1.326 -			Army army = new Army(mockRace, "Test", 1000);
   1.327 -			AddUnitOfTypeToArmy(unitType1, army);
   1.328  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.329  			req.AddUnitTypeRequirement(unitType2);
   1.330 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 1)."));
   1.331 +			req.AddUnitTypeRequirement(unitType3);
   1.332 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."));
   1.333  		}
   1.334  
   1.335  		[Test]
   1.336 @@ -239,15 +308,15 @@
   1.337  		{
   1.338  			Army army = new Army(mockRace, "Test", 1000);
   1.339  			AddUnitOfTypeToArmy(unitType1, army);
   1.340 -			AddUnitOfTypeToArmy(unitType2, army);
   1.341 +			AddUnitOfTypeToArmy(unitType1, army);
   1.342  			AddUnitOfTypeToArmy(unitType2, army);
   1.343  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.344  			req.AddUnitTypeRequirement(unitType2, 2);
   1.345 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 3)."));
   1.346 +			Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 1 for 3)."));
   1.347  		}
   1.348  
   1.349  		[Test]
   1.350 -		public void TestAllowsAddMessageIsCorrectForFailWithTwoUnitsProhibited()
   1.351 +		public void TestAllowsAddMessageIsCorrectForFailWithTwoUnitsRequired()
   1.352  		{
   1.353  			Army army = new Army(mockRace, "Test", 1000);
   1.354  			AddUnitOfTypeToArmy(unitType1, army);
   1.355 @@ -258,27 +327,61 @@
   1.356  		}
   1.357  
   1.358  		[Test]
   1.359 -		public void TestAllowsAddMessageIsCorrectForFailWithTwoUnitsProhibitedAndOneUnitInArmy()
   1.360 +		public void TestAllowsAddMessageIsCorrectForFailWithTwoUnitsRequiredAndOneUnitInArmy()
   1.361  		{
   1.362  			Army army = new Army(mockRace, "Test", 1000);
   1.363 -			AddUnitOfTypeToArmy(unitType1, army);
   1.364  			AddUnitOfTypeToArmy(unitType2, army);
   1.365  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.366  			req.AddUnitTypeRequirement(unitType2);
   1.367  			req.AddUnitTypeRequirement(unitType3);
   1.368 -			Assert.That(req.GetAllowsAddingMessage(unitType3, army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 1); 0 × " + unitType3.Name + " for every " + unitType1.Name + " (would have 1)."));
   1.369 +			Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."));
   1.370  		}
   1.371  
   1.372  		[Test]
   1.373 -		public void TestAllowsAddMessageIsCorrectForFailWithTwoUnitsProhibitedAndOtherUnitInArmy()
   1.374 +		public void TestAllowsAddMessageIsCorrectForFailWithTwoUnitsRequiredAndOtherUnitInArmy()
   1.375  		{
   1.376  			Army army = new Army(mockRace, "Test", 1000);
   1.377 -			AddUnitOfTypeToArmy(unitType1, army);
   1.378  			AddUnitOfTypeToArmy(unitType3, army);
   1.379  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.380  			req.AddUnitTypeRequirement(unitType2);
   1.381  			req.AddUnitTypeRequirement(unitType3);
   1.382 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 1); 0 × " + unitType3.Name + " for every " + unitType1.Name + " (would have 1)."));
   1.383 +			Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."));
   1.384 +		}
   1.385 +
   1.386 +		private static void Assert_That__PassesAdding(UnitRequiresNUnitsForMUnitsRequirement req, UnitType unitType, Army army)
   1.387 +		{
   1.388 +			Assert.That(req.AllowsAdding(unitType, army), Is.EqualTo(Validation.Passed));
   1.389 +			Assert.That(req.GetAllowsAddingMessage(unitType, army), Is.Empty);
   1.390 +		}
   1.391 +
   1.392 +		private static void Assert_That__PassesAdding(UnitRequiresNUnitsForMUnitsRequirement req, Unit unit, Army army)
   1.393 +		{
   1.394 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
   1.395 +			Assert.That(req.GetAllowsAddingMessage(unit, army), Is.Empty);
   1.396 +		}
   1.397 +
   1.398 +		private static void Assert_That__AddingNotApplicable(UnitRequiresNUnitsForMUnitsRequirement req, UnitType unitType, Army army)
   1.399 +		{
   1.400 +			Assert.That(req.AllowsAdding(unitType, army), Is.EqualTo(Validation.NotApplicable));
   1.401 +			Assert.That(req.GetAllowsAddingMessage(unitType, army), Is.Empty);
   1.402 +		}
   1.403 +
   1.404 +		private static void Assert_That__AddingNotApplicable(UnitRequiresNUnitsForMUnitsRequirement req, Unit unit, Army army)
   1.405 +		{
   1.406 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.NotApplicable));
   1.407 +			Assert.That(req.GetAllowsAddingMessage(unit, army), Is.Empty);
   1.408 +		}
   1.409 +
   1.410 +		private static void Assert_That__FailsAdding(UnitRequiresNUnitsForMUnitsRequirement req, UnitType unitType, Army army, string message)
   1.411 +		{
   1.412 +			Assert.That(req.AllowsAdding(unitType, army), Is.EqualTo(Validation.Failed));
   1.413 +			Assert.That(req.GetAllowsAddingMessage(unitType, army), Is.EqualTo(message));
   1.414 +		}
   1.415 +
   1.416 +		private static void Assert_That__FailsAdding(UnitRequiresNUnitsForMUnitsRequirement req, Unit unit, Army army, string message)
   1.417 +		{
   1.418 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
   1.419 +			Assert.That(req.GetAllowsAddingMessage(unit, army), Is.EqualTo(message));
   1.420  		}
   1.421  
   1.422  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)