changeset 144:eced294e82f2

Re #345: Add failure message to requirements * Add tests for "no more than" requirements
author IBBoard <dev@ibboard.co.uk>
date Sun, 01 May 2011 15:38:01 +0000
parents 6fdb76d48e04
children 0d40d80226b8
files API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirementTest.cs
diffstat 2 files changed, 263 insertions(+), 130 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Sun May 01 14:45:22 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Sun May 01 15:38:01 2011 +0000
     1.3 @@ -110,6 +110,69 @@
     1.4  			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
     1.5  		}
     1.6  
     1.7 +		[Test]
     1.8 +		public void TestValidationMessageIsBlankForPass()
     1.9 +		{
    1.10 +			Army army = new Army(mockRace, "Test", 1000);
    1.11 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    1.12 +			Assert.That(req.GetValidationMessage(army), Is.Empty);
    1.13 +		}
    1.14 +
    1.15 +		[Test]
    1.16 +		public void TestValidationMessageIsCorrectForFailWithOneUnitProhibited()
    1.17 +		{
    1.18 +			Army army = new Army(mockRace, "Test", 1000);
    1.19 +			AddUnitOfTypeToArmy(unitType1, army);
    1.20 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    1.21 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType1.Name + " (have 1)."));
    1.22 +		}
    1.23 +
    1.24 +		[Test]
    1.25 +		public void TestValidationMessageIsCorrectForFailWithTwoOfOneUnitLimit()
    1.26 +		{
    1.27 +			Army army = new Army(mockRace, "Test", 1000);
    1.28 +			AddUnitOfTypeToArmy(unitType1, army);
    1.29 +			AddUnitOfTypeToArmy(unitType1, army);
    1.30 +			AddUnitOfTypeToArmy(unitType1, army);
    1.31 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.32 +			req.AddUnitTypeRequirement(unitType1, 2);
    1.33 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 2 × " + unitType1.Name + " (have 3)."));
    1.34 +		}
    1.35 +
    1.36 +		[Test]
    1.37 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibited()
    1.38 +		{
    1.39 +			Army army = new Army(mockRace, "Test", 1000);
    1.40 +			AddUnitOfTypeToArmy(unitType1, army);
    1.41 +			AddUnitOfTypeToArmy(unitType2, army);
    1.42 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.43 +			req.AddUnitTypeRequirement(unitType1);
    1.44 +			req.AddUnitTypeRequirement(unitType2);
    1.45 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType1.Name + " (have 1); 0 × " + unitType2.Name + " (have 1)."));
    1.46 +		}
    1.47 +
    1.48 +		[Test]
    1.49 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibitedAndOneUnitInArmy()
    1.50 +		{
    1.51 +			Army army = new Army(mockRace, "Test", 1000);
    1.52 +			AddUnitOfTypeToArmy(unitType1, army);
    1.53 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.54 +			req.AddUnitTypeRequirement(unitType1);
    1.55 +			req.AddUnitTypeRequirement(unitType2);
    1.56 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType1.Name + " (have 1)."));
    1.57 +		}
    1.58 +
    1.59 +		[Test]
    1.60 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibitedAndOtherUnitInArmy()
    1.61 +		{
    1.62 +			Army army = new Army(mockRace, "Test", 1000);
    1.63 +			AddUnitOfTypeToArmy(unitType2, army);
    1.64 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.65 +			req.AddUnitTypeRequirement(unitType1);
    1.66 +			req.AddUnitTypeRequirement(unitType2);
    1.67 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (have 1)."));
    1.68 +		}
    1.69 +
    1.70  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
    1.71  		{
    1.72  			army.AddUnit(CreateUnitOfType(unitType, army));
     2.1 --- a/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Sun May 01 14:45:22 2011 +0000
     2.2 +++ b/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Sun May 01 15:38:01 2011 +0000
     2.3 @@ -1,157 +1,227 @@
     2.4 -// This file (RequiresNoMoreThanNOfUnitTypeRequirementTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
     2.5 +// This file (RequiresNoMoreThanNOfUnitTypeRequirementTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
     2.6  // 
     2.7  // 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.
     2.8  using System;
     2.9 -using NUnit.Framework;
    2.10 -using IBBoard.WarFoundry.API.Objects.Mock;
    2.11 +using NUnit.Framework;
    2.12 +using IBBoard.WarFoundry.API.Objects.Mock;
    2.13  using NUnit.Framework.SyntaxHelpers;
    2.14  
    2.15  namespace IBBoard.WarFoundry.API.Objects.Requirement
    2.16  {
    2.17  	[TestFixture()]
    2.18  	public class UnitRequiresNoMoreThanNOfUnitTypeRequirementTest
    2.19 -	{
    2.20 -		private MockRace mockRace;
    2.21 -		private UnitType unitType1;
    2.22 -		private UnitType unitType2;
    2.23 -		private UnitType unitType3;
    2.24 -
    2.25 -		[TestFixtureSetUp()]
    2.26 -		public void SetupRace()
    2.27 -		{
    2.28 -			mockRace = new MockRace();
    2.29 -			unitType1 = new MockUnitType("type1", "Unit Type 1");
    2.30 -			mockRace.AddUnitType(unitType1);
    2.31 -			unitType2 = new MockUnitType("type2", "Unit Type 2");
    2.32 -			mockRace.AddUnitType(unitType2);
    2.33 -			unitType3 = new MockUnitType("type3", "Unit Type 3");
    2.34 -			mockRace.AddUnitType(unitType3);
    2.35 -		}
    2.36 -
    2.37 -		[Test()]
    2.38 -		public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
    2.39 -		{
    2.40 -			Army army = new Army(mockRace, "Test", 1000);
    2.41 -			Unit unit = CreateUnitOfType(unitType1, army);
    2.42 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    2.43 -			req.AddUnitTypeRequirement(unitType2);
    2.44 -			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
    2.45 -		}
    2.46 -
    2.47 -		[Test()]
    2.48 -		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
    2.49 -		{
    2.50 -			Army army = new Army(mockRace, "Test", 1000);
    2.51 -			AddUnitOfTypeToArmy(unitType2, army);
    2.52 -			Unit unit = CreateUnitOfType(unitType1, army);
    2.53 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    2.54 -			req.AddUnitTypeRequirement(unitType2);
    2.55 -			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
    2.56 -		}
    2.57 -
    2.58 -		[Test()]
    2.59 -		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
    2.60 -		{
    2.61 -			Army army = new Army(mockRace, "Test", 1000);
    2.62 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    2.63 -			req.AddUnitTypeRequirement(unitType2);
    2.64 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    2.65 -		}
    2.66 -
    2.67 -		[Test()]
    2.68 -		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
    2.69 -		{
    2.70 -			Army army = new Army(mockRace, "Test", 1000);
    2.71 -			AddUnitOfTypeToArmy(unitType2, army);
    2.72 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    2.73 -			req.AddUnitTypeRequirement(unitType2);
    2.74 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    2.75 -		}
    2.76 -
    2.77 -		[Test()]
    2.78 -		public void TestAddingUnitTypeSetsLimit()
    2.79 -		{
    2.80 -			Army army = new Army(mockRace, "Test", 1000);
    2.81 -			AddUnitOfTypeToArmy(unitType2, army);
    2.82 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    2.83 -			req.AddUnitTypeRequirement(unitType2, 1);
    2.84 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    2.85 -		}
    2.86 -
    2.87 -		[Test()]
    2.88 -		public void TestAddingUnitTypeSetsLimitForFailure()
    2.89 -		{
    2.90 -			Army army = new Army(mockRace, "Test", 1000);
    2.91 -			AddUnitOfTypeToArmy(unitType2, army);
    2.92 -			AddUnitOfTypeToArmy(unitType2, army);
    2.93 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    2.94 -			req.AddUnitTypeRequirement(unitType2, 1);
    2.95 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    2.96 -		}
    2.97 -
    2.98 -		[Test()]
    2.99 -		public void TestAddingUnitTriggersFailure()
   2.100 -		{
   2.101 -			Army army = new Army(mockRace, "Test", 1000);
   2.102 -			AddUnitOfTypeToArmy(unitType2, army);
   2.103 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.104 -			req.AddUnitTypeRequirement(unitType2, 1);
   2.105 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   2.106 -			AddUnitOfTypeToArmy(unitType2, army);
   2.107 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   2.108 -		}
   2.109 -
   2.110 -		[Test()]
   2.111 -		public void TestAddingUnitTypeDefaultsToNoMoreThanZero()
   2.112 -		{
   2.113 -			Army army = new Army(mockRace, "Test", 1000);
   2.114 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.115 -			req.AddUnitTypeRequirement(unitType2);
   2.116 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   2.117 -			AddUnitOfTypeToArmy(unitType2, army);
   2.118 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   2.119 +	{
   2.120 +		private MockRace mockRace;
   2.121 +		private UnitType unitType1;
   2.122 +		private UnitType unitType2;
   2.123 +		private UnitType unitType3;
   2.124 +
   2.125 +		[TestFixtureSetUp()]
   2.126 +		public void SetupRace()
   2.127 +		{
   2.128 +			mockRace = new MockRace();
   2.129 +			unitType1 = new MockUnitType("type1", "Unit Type 1");
   2.130 +			mockRace.AddUnitType(unitType1);
   2.131 +			unitType2 = new MockUnitType("type2", "Unit Type 2");
   2.132 +			mockRace.AddUnitType(unitType2);
   2.133 +			unitType3 = new MockUnitType("type3", "Unit Type 3");
   2.134 +			mockRace.AddUnitType(unitType3);
   2.135 +		}
   2.136 +
   2.137 +		[Test()]
   2.138 +		public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
   2.139 +		{
   2.140 +			Army army = new Army(mockRace, "Test", 1000);
   2.141 +			Unit unit = CreateUnitOfType(unitType1, army);
   2.142 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.143 +			req.AddUnitTypeRequirement(unitType2);
   2.144 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
   2.145 +		}
   2.146 +
   2.147 +		[Test()]
   2.148 +		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
   2.149 +		{
   2.150 +			Army army = new Army(mockRace, "Test", 1000);
   2.151 +			AddUnitOfTypeToArmy(unitType2, army);
   2.152 +			Unit unit = CreateUnitOfType(unitType1, army);
   2.153 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.154 +			req.AddUnitTypeRequirement(unitType2);
   2.155 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
   2.156 +		}
   2.157 +
   2.158 +		[Test()]
   2.159 +		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
   2.160 +		{
   2.161 +			Army army = new Army(mockRace, "Test", 1000);
   2.162 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.163 +			req.AddUnitTypeRequirement(unitType2);
   2.164 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   2.165 +		}
   2.166 +
   2.167 +		[Test()]
   2.168 +		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
   2.169 +		{
   2.170 +			Army army = new Army(mockRace, "Test", 1000);
   2.171 +			AddUnitOfTypeToArmy(unitType2, army);
   2.172 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.173 +			req.AddUnitTypeRequirement(unitType2);
   2.174 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   2.175 +		}
   2.176 +
   2.177 +		[Test()]
   2.178 +		public void TestAddingUnitTypeSetsLimit()
   2.179 +		{
   2.180 +			Army army = new Army(mockRace, "Test", 1000);
   2.181 +			AddUnitOfTypeToArmy(unitType2, army);
   2.182 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.183 +			req.AddUnitTypeRequirement(unitType2, 1);
   2.184 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   2.185 +		}
   2.186 +
   2.187 +		[Test()]
   2.188 +		public void TestAddingUnitTypeSetsLimitForFailure()
   2.189 +		{
   2.190 +			Army army = new Army(mockRace, "Test", 1000);
   2.191 +			AddUnitOfTypeToArmy(unitType2, army);
   2.192 +			AddUnitOfTypeToArmy(unitType2, army);
   2.193 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.194 +			req.AddUnitTypeRequirement(unitType2, 1);
   2.195 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   2.196 +		}
   2.197 +
   2.198 +		[Test()]
   2.199 +		public void TestAddingUnitTriggersFailure()
   2.200 +		{
   2.201 +			Army army = new Army(mockRace, "Test", 1000);
   2.202 +			AddUnitOfTypeToArmy(unitType2, army);
   2.203 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.204 +			req.AddUnitTypeRequirement(unitType2, 1);
   2.205 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   2.206 +			AddUnitOfTypeToArmy(unitType2, army);
   2.207 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   2.208 +		}
   2.209 +
   2.210 +		[Test()]
   2.211 +		public void TestAddingUnitTypeDefaultsToNoMoreThanZero()
   2.212 +		{
   2.213 +			Army army = new Army(mockRace, "Test", 1000);
   2.214 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.215 +			req.AddUnitTypeRequirement(unitType2);
   2.216 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   2.217 +			AddUnitOfTypeToArmy(unitType2, army);
   2.218 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   2.219 +		}
   2.220 +
   2.221 +		[Test]
   2.222 +		public void TestRequirementNotApplicableWhenLimitedUnitNotIncluded()
   2.223 +		{
   2.224 +			Army army = new Army(mockRace, "Test", 1000);
   2.225 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.226 +			req.AddUnitTypeRequirement(unitType2);
   2.227 +			Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable));
   2.228 +			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.NotApplicable));
   2.229 +		}
   2.230 +
   2.231 +		[Test]
   2.232 +		public void TestRequirementBecomesInvalidWhenProhibitedUnitsChange()
   2.233 +		{
   2.234 +			Army army = new Army(mockRace, "Test", 1000);
   2.235 +			AddUnitOfTypeToArmy(unitType1, army);
   2.236 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.237 +			req.AddUnitTypeRequirement(unitType2);
   2.238 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   2.239 +			AddUnitOfTypeToArmy(unitType2, army);
   2.240 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   2.241 +		}
   2.242 +
   2.243 +		[Test()]
   2.244 +		public void TestAddingLimitedUnitTriggersFailure()
   2.245 +		{
   2.246 +			Army army = new Army(mockRace, "Test", 1000);
   2.247 +			AddUnitOfTypeToArmy(unitType1, army);
   2.248 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.249 +			req.AddUnitTypeRequirement(unitType2);
   2.250 +			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
   2.251 +		}
   2.252 +
   2.253 +		[Test]
   2.254 +		public void TestValidationMessageIsBlankForPass()
   2.255 +		{
   2.256 +			Army army = new Army(mockRace, "Test", 1000);
   2.257 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.258 +			req.AddUnitTypeRequirement(unitType2);
   2.259 +			Assert.That(req.GetValidationMessage(army), Is.Empty);
   2.260 +		}
   2.261 +
   2.262 +		[Test]
   2.263 +		public void TestValidationMessageIsCorrectForFailWithOneUnitProhibited()
   2.264 +		{
   2.265 +			Army army = new Army(mockRace, "Test", 1000);
   2.266 +			AddUnitOfTypeToArmy(unitType1, army);
   2.267 +			AddUnitOfTypeToArmy(unitType2, army);
   2.268 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.269 +			req.AddUnitTypeRequirement(unitType2);
   2.270 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so cannot contain more than: 0 × " + unitType2.Name + " (have 1)."));
   2.271 +		}
   2.272 +
   2.273 +		[Test]
   2.274 +		public void TestValidationMessageIsCorrectForFailWithTwoOfOneUnitLimit()
   2.275 +		{
   2.276 +			Army army = new Army(mockRace, "Test", 1000);
   2.277 +			AddUnitOfTypeToArmy(unitType1, army);
   2.278 +			AddUnitOfTypeToArmy(unitType2, army);
   2.279 +			AddUnitOfTypeToArmy(unitType2, army);
   2.280 +			AddUnitOfTypeToArmy(unitType2, army);
   2.281 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.282 +			req.AddUnitTypeRequirement(unitType2, 2);
   2.283 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so cannot contain more than: 2 × " + unitType2.Name + " (have 3)."));
   2.284 +		}
   2.285 +
   2.286 +		[Test]
   2.287 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibited()
   2.288 +		{
   2.289 +			Army army = new Army(mockRace, "Test", 1000);
   2.290 +			AddUnitOfTypeToArmy(unitType1, army);
   2.291 +			AddUnitOfTypeToArmy(unitType2, army);
   2.292 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.293 +			req.AddUnitTypeRequirement(unitType2);
   2.294 +			req.AddUnitTypeRequirement(unitType3);
   2.295 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so cannot contain more than: 0 × " + unitType2.Name + " (have 1)."));
   2.296  		}
   2.297  
   2.298  		[Test]
   2.299 -		public void TestRequirementNotApplicableWhenLimitedUnitNotIncluded()
   2.300 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibitedAndOtherUnitInArmy()
   2.301  		{
   2.302  			Army army = new Army(mockRace, "Test", 1000);
   2.303 +			AddUnitOfTypeToArmy(unitType1, army);
   2.304 +			AddUnitOfTypeToArmy(unitType3, army);
   2.305  			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.306  			req.AddUnitTypeRequirement(unitType2);
   2.307 -			Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable));
   2.308 -			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.NotApplicable));
   2.309 +			req.AddUnitTypeRequirement(unitType3);
   2.310 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so cannot contain more than: 0 × " + unitType3.Name + " (have 1)."));
   2.311  		}
   2.312  
   2.313  		[Test]
   2.314 -		public void TestRequirementBecomesInvalidWhenProhibitedUnitsChange()
   2.315 +		public void TestValidationMessageIsCorrectForFailWithTwoUnitsProhibitedAndBothUnitsInArmy()
   2.316  		{
   2.317  			Army army = new Army(mockRace, "Test", 1000);
   2.318  			AddUnitOfTypeToArmy(unitType1, army);
   2.319 +			AddUnitOfTypeToArmy(unitType2, army);
   2.320 +			AddUnitOfTypeToArmy(unitType3, army);
   2.321  			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.322  			req.AddUnitTypeRequirement(unitType2);
   2.323 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   2.324 -			AddUnitOfTypeToArmy(unitType2, army);
   2.325 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   2.326 -		}
   2.327 -
   2.328 -		[Test()]
   2.329 -		public void TestAddingLimitedUnitTriggersFailure()
   2.330 -		{
   2.331 -			Army army = new Army(mockRace, "Test", 1000);
   2.332 -			AddUnitOfTypeToArmy(unitType1, army);
   2.333 -			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
   2.334 -			req.AddUnitTypeRequirement(unitType2);
   2.335 -			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
   2.336 -		}
   2.337 -
   2.338 -		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
   2.339 -		{
   2.340 -			army.AddUnit(CreateUnitOfType(unitType, army));
   2.341 -		}
   2.342 -
   2.343 -		private static Unit CreateUnitOfType(UnitType unitType, Army army)
   2.344 -		{
   2.345 -			return new Unit(unitType, army.GetCategory(unitType.MainCategory));
   2.346 +			req.AddUnitTypeRequirement(unitType3);
   2.347 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so cannot contain more than: 0 × " + unitType2.Name + " (have 1); 0 × " + unitType3.Name + " (have 1)."));
   2.348 +		}
   2.349 +
   2.350 +		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
   2.351 +		{
   2.352 +			army.AddUnit(CreateUnitOfType(unitType, army));
   2.353 +		}
   2.354 +
   2.355 +		private static Unit CreateUnitOfType(UnitType unitType, Army army)
   2.356 +		{
   2.357 +			return new Unit(unitType, army.GetCategory(unitType.MainCategory));
   2.358  		}
   2.359  	}
   2.360  }