changeset 132:8f1af48e120c

Re #27: Unit requirements * Add unit test for unit requirements in opposite order * Add unit test to make sure that requirement doesn't lock to first result, even after changes Also: * Clean up line endings to meet policy
author IBBoard <dev@ibboard.co.uk>
date Sun, 17 Apr 2011 19:34:48 +0000
parents 5ede1c0a1454
children f64742dde5f9
files API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs
diffstat 1 files changed, 236 insertions(+), 213 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs	Sat Apr 16 19:49:22 2011 +0000
     1.2 +++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs	Sun Apr 17 19:34:48 2011 +0000
     1.3 @@ -1,213 +1,236 @@
     1.4 -// This file (UnitRequiresAtLeastNUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
     1.5 -// 
     1.6 -// 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.
     1.7 -using System;
     1.8 -using NUnit.Framework;
     1.9 -using IBBoard.WarFoundry.API.Objects.Mock;
    1.10 -using NUnit.Framework.SyntaxHelpers;
    1.11 -
    1.12 -namespace IBBoard.WarFoundry.API.Objects.Requirement
    1.13 -{
    1.14 -	[TestFixture()]
    1.15 -	public class UnitRequiresAtLeastNUnitsRequirementTest
    1.16 -	{
    1.17 -		private MockRace mockRace;
    1.18 -		private UnitType unitType1;
    1.19 -		private UnitType unitType2;
    1.20 -		private UnitType unitType3;
    1.21 -
    1.22 -		[TestFixtureSetUp()]
    1.23 -		public void SetupRace()
    1.24 -		{
    1.25 -			mockRace = new MockRace();
    1.26 -			unitType1 = new MockUnitType("type1", "Unit Type 1");
    1.27 -			mockRace.AddUnitType(unitType1);
    1.28 -			unitType2 = new MockUnitType("type2", "Unit Type 2");
    1.29 -			mockRace.AddUnitType(unitType2);
    1.30 -			unitType3 = new MockUnitType("type3", "Unit Type 3");
    1.31 -			mockRace.AddUnitType(unitType3);
    1.32 -		}
    1.33 -
    1.34 -		[Test()]
    1.35 -		public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequired()
    1.36 -		{
    1.37 -			Army army = new Army(mockRace, "Test", 1000);
    1.38 -			Unit unit = CreateUnitOfType(unitType1, army);
    1.39 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
    1.40 -			req.AddUnitTypeRequirement(unitType2);
    1.41 -			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
    1.42 -		}
    1.43 -
    1.44 -		[Test()]
    1.45 -		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequired()
    1.46 -		{
    1.47 -			Army army = new Army(mockRace, "Test", 1000);
    1.48 -			AddUnitOfTypeToArmy(unitType2, army);
    1.49 -			Unit unit = CreateUnitOfType(unitType1, army);
    1.50 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
    1.51 -			req.AddUnitTypeRequirement(unitType2);
    1.52 -			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
    1.53 -		}
    1.54 -
    1.55 -		[Test()]
    1.56 -		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
    1.57 -		{
    1.58 -			Army army = new Army(mockRace, "Test", 1000);
    1.59 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
    1.60 -			req.AddUnitTypeRequirement(unitType2);
    1.61 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.62 -		}
    1.63 -
    1.64 -		[Test()]
    1.65 -		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
    1.66 -		{
    1.67 -			Army army = new Army(mockRace, "Test", 1000);
    1.68 -			AddUnitOfTypeToArmy(unitType2, army);
    1.69 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
    1.70 -			req.AddUnitTypeRequirement(unitType2);
    1.71 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.72 -		}
    1.73 -
    1.74 -		[Test()]
    1.75 -		public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
    1.76 -		{
    1.77 -			Army army = new Army(mockRace, "Test", 1000);
    1.78 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
    1.79 -			req.AddUnitTypeRequirement(unitType2);
    1.80 -			req.AddUnitTypeRequirement(unitType3);
    1.81 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.82 -		}
    1.83 -
    1.84 -		[Test()]
    1.85 -		public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
    1.86 -		{
    1.87 -			Army army = new Army(mockRace, "Test", 1000);
    1.88 -			AddUnitOfTypeToArmy(unitType2, army);
    1.89 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
    1.90 -			req.AddUnitTypeRequirement(unitType2);
    1.91 -			req.AddUnitTypeRequirement(unitType3);
    1.92 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.93 -		}
    1.94 -
    1.95 -		[Test()]
    1.96 -		public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
    1.97 -		{
    1.98 -			Army army = new Army(mockRace, "Test", 1000);
    1.99 -			AddUnitOfTypeToArmy(unitType2, army);
   1.100 -			AddUnitOfTypeToArmy(unitType3, army);
   1.101 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.102 -			req.AddUnitTypeRequirement(unitType2);
   1.103 -			req.AddUnitTypeRequirement(unitType3);
   1.104 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.105 -		}
   1.106 -
   1.107 -		[Test()]
   1.108 -		public void TestAddingUnitTypeWithOneUnitAndTwoOfOneUnitTypeRequired()
   1.109 -		{
   1.110 -			Army army = new Army(mockRace, "Test", 1000);
   1.111 -			AddUnitOfTypeToArmy(unitType2, army);
   1.112 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.113 -			req.AddUnitTypeRequirement(unitType2, 2);
   1.114 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.115 -		}
   1.116 -
   1.117 -		[Test()]
   1.118 -		public void TestAddingUnrelatedUnitTypeIsAllowedWhenRequirementsNotMet()
   1.119 -		{
   1.120 -			Army army = new Army(mockRace, "Test", 1000);
   1.121 -			AddUnitOfTypeToArmy(unitType2, army);
   1.122 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.123 -			req.AddUnitTypeRequirement(unitType2, 2);
   1.124 -			Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable));
   1.125 -		}
   1.126 -
   1.127 -		[Test()]
   1.128 -		public void TestAddingUnitTypeWithTwoUnitsAndTwoOfOneUnitTypeRequired()
   1.129 -		{
   1.130 -			Army army = new Army(mockRace, "Test", 1000);
   1.131 -			AddUnitOfTypeToArmy(unitType2, army);
   1.132 -			AddUnitOfTypeToArmy(unitType2, army);
   1.133 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.134 -			req.AddUnitTypeRequirement(unitType2, 2);
   1.135 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.136 -		}
   1.137 -
   1.138 -		[Test()]
   1.139 -		public void TestAddingUnitTypeRequirementWithNoNumberDefaultsToHavingOne()
   1.140 -		{
   1.141 -			Army army = new Army(mockRace, "Test", 1000);
   1.142 -			AddUnitOfTypeToArmy(unitType2, army);
   1.143 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.144 -			req.AddUnitTypeRequirement(unitType2);
   1.145 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.146 -		}
   1.147 -
   1.148 -		[Test()]
   1.149 -		public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
   1.150 -		{
   1.151 -			Army army = new Army(mockRace, "Test", 1000);
   1.152 -			AddUnitOfTypeToArmy(unitType1, army);
   1.153 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.154 -			req.AddUnitTypeRequirement(unitType2);
   1.155 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   1.156 -		}
   1.157 -
   1.158 -		[Test()]
   1.159 -		public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
   1.160 -		{
   1.161 -			Army army = new Army(mockRace, "Test", 1000);
   1.162 -			AddUnitOfTypeToArmy(unitType2, army);
   1.163 -			AddUnitOfTypeToArmy(unitType1, army);
   1.164 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.165 -			req.AddUnitTypeRequirement(unitType2);
   1.166 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   1.167 -		}
   1.168 -
   1.169 -		[Test()]
   1.170 -		public void TestValidityOfArmyWhenNoRequireeAndRequirementNotMet()
   1.171 -		{
   1.172 -			Army army = new Army(mockRace, "Test", 1000);
   1.173 -			AddUnitOfTypeToArmy(unitType2, army);
   1.174 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.175 -			req.AddUnitTypeRequirement(unitType2, 2);
   1.176 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
   1.177 -		}
   1.178 -
   1.179 -		[Test]
   1.180 -		public void TestSatisfyingRequirementChangesResult()
   1.181 -		{
   1.182 -			Army army = new Army(mockRace, "Test", 1000);
   1.183 -			AddUnitOfTypeToArmy(unitType1, army);
   1.184 -			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.185 -			req.AddUnitTypeRequirement(unitType2);
   1.186 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   1.187 -			AddUnitOfTypeToArmy(unitType2, army);
   1.188 -			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   1.189 -		}
   1.190 -
   1.191 -		[Test]
   1.192 -		public void TestAddingMinNumberUnitTypePassesRequirement()
   1.193 -		{
   1.194 -			Army army = new Army(mockRace, "Test", 1000);
   1.195 -			AddUnitOfTypeToArmy(unitType1, army);
   1.196 -			RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.197 -			req.AddUnitTypeRequirement(unitType2, 2);
   1.198 -			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
   1.199 -			AddUnitOfTypeToArmy(unitType2, army);
   1.200 -			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
   1.201 -		}
   1.202 -
   1.203 -
   1.204 -		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
   1.205 -		{
   1.206 -			army.AddUnit(CreateUnitOfType(unitType, army));
   1.207 -		}
   1.208 -
   1.209 -
   1.210 -		private static Unit CreateUnitOfType(UnitType unitType, Army army)
   1.211 -		{
   1.212 -			return new Unit(unitType, army.GetCategory(unitType.MainCategory));
   1.213 -		}
   1.214 -	}
   1.215 -}
   1.216 -
   1.217 +// This file (UnitRequiresAtLeastNUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
   1.218 +// 
   1.219 +// 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.
   1.220 +using System;
   1.221 +using NUnit.Framework;
   1.222 +using IBBoard.WarFoundry.API.Objects.Mock;
   1.223 +using NUnit.Framework.SyntaxHelpers;
   1.224 +
   1.225 +namespace IBBoard.WarFoundry.API.Objects.Requirement
   1.226 +{
   1.227 +	[TestFixture()]
   1.228 +	public class UnitRequiresAtLeastNUnitsRequirementTest
   1.229 +	{
   1.230 +		private MockRace mockRace;
   1.231 +		private UnitType unitType1;
   1.232 +		private UnitType unitType2;
   1.233 +		private UnitType unitType3;
   1.234 +
   1.235 +		[TestFixtureSetUp()]
   1.236 +		public void SetupRace()
   1.237 +		{
   1.238 +			mockRace = new MockRace();
   1.239 +			unitType1 = new MockUnitType("type1", "Unit Type 1");
   1.240 +			mockRace.AddUnitType(unitType1);
   1.241 +			unitType2 = new MockUnitType("type2", "Unit Type 2");
   1.242 +			mockRace.AddUnitType(unitType2);
   1.243 +			unitType3 = new MockUnitType("type3", "Unit Type 3");
   1.244 +			mockRace.AddUnitType(unitType3);
   1.245 +		}
   1.246 +
   1.247 +		[Test()]
   1.248 +		public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequired()
   1.249 +		{
   1.250 +			Army army = new Army(mockRace, "Test", 1000);
   1.251 +			Unit unit = CreateUnitOfType(unitType1, army);
   1.252 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.253 +			req.AddUnitTypeRequirement(unitType2);
   1.254 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
   1.255 +		}
   1.256 +
   1.257 +		[Test()]
   1.258 +		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequired()
   1.259 +		{
   1.260 +			Army army = new Army(mockRace, "Test", 1000);
   1.261 +			AddUnitOfTypeToArmy(unitType2, army);
   1.262 +			Unit unit = CreateUnitOfType(unitType1, army);
   1.263 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.264 +			req.AddUnitTypeRequirement(unitType2);
   1.265 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
   1.266 +		}
   1.267 +
   1.268 +		[Test()]
   1.269 +		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
   1.270 +		{
   1.271 +			Army army = new Army(mockRace, "Test", 1000);
   1.272 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.273 +			req.AddUnitTypeRequirement(unitType2);
   1.274 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.275 +		}
   1.276 +
   1.277 +		[Test()]
   1.278 +		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
   1.279 +		{
   1.280 +			Army army = new Army(mockRace, "Test", 1000);
   1.281 +			AddUnitOfTypeToArmy(unitType2, army);
   1.282 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.283 +			req.AddUnitTypeRequirement(unitType2);
   1.284 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.285 +		}
   1.286 +
   1.287 +		[Test()]
   1.288 +		public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
   1.289 +		{
   1.290 +			Army army = new Army(mockRace, "Test", 1000);
   1.291 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.292 +			req.AddUnitTypeRequirement(unitType2);
   1.293 +			req.AddUnitTypeRequirement(unitType3);
   1.294 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.295 +		}
   1.296 +
   1.297 +		[Test()]
   1.298 +		public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
   1.299 +		{
   1.300 +			Army army = new Army(mockRace, "Test", 1000);
   1.301 +			AddUnitOfTypeToArmy(unitType2, army);
   1.302 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.303 +			req.AddUnitTypeRequirement(unitType2);
   1.304 +			req.AddUnitTypeRequirement(unitType3);
   1.305 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.306 +		}
   1.307 +
   1.308 +		[Test()]
   1.309 +		public void TestAddingUnitTypeWithOtherOneUnitAndTwoUnitTypesRequired()
   1.310 +		{
   1.311 +			Army army = new Army(mockRace, "Test", 1000);
   1.312 +			AddUnitOfTypeToArmy(unitType3, army);
   1.313 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.314 +			req.AddUnitTypeRequirement(unitType2);
   1.315 +			req.AddUnitTypeRequirement(unitType3);
   1.316 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.317 +		}
   1.318 +
   1.319 +		[Test()]
   1.320 +		public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
   1.321 +		{
   1.322 +			Army army = new Army(mockRace, "Test", 1000);
   1.323 +			AddUnitOfTypeToArmy(unitType2, army);
   1.324 +			AddUnitOfTypeToArmy(unitType3, army);
   1.325 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.326 +			req.AddUnitTypeRequirement(unitType2);
   1.327 +			req.AddUnitTypeRequirement(unitType3);
   1.328 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.329 +		}
   1.330 +
   1.331 +		[Test()]
   1.332 +		public void TestAddingUnitTypeWithOneUnitAndTwoOfOneUnitTypeRequired()
   1.333 +		{
   1.334 +			Army army = new Army(mockRace, "Test", 1000);
   1.335 +			AddUnitOfTypeToArmy(unitType2, army);
   1.336 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.337 +			req.AddUnitTypeRequirement(unitType2, 2);
   1.338 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.339 +		}
   1.340 +
   1.341 +		[Test()]
   1.342 +		public void TestAddingUnrelatedUnitTypeIsAllowedWhenRequirementsNotMet()
   1.343 +		{
   1.344 +			Army army = new Army(mockRace, "Test", 1000);
   1.345 +			AddUnitOfTypeToArmy(unitType2, army);
   1.346 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.347 +			req.AddUnitTypeRequirement(unitType2, 2);
   1.348 +			Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable));
   1.349 +		}
   1.350 +
   1.351 +		[Test()]
   1.352 +		public void TestAddingUnitTypeWithTwoUnitsAndTwoOfOneUnitTypeRequired()
   1.353 +		{
   1.354 +			Army army = new Army(mockRace, "Test", 1000);
   1.355 +			AddUnitOfTypeToArmy(unitType2, army);
   1.356 +			AddUnitOfTypeToArmy(unitType2, army);
   1.357 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.358 +			req.AddUnitTypeRequirement(unitType2, 2);
   1.359 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.360 +		}
   1.361 +
   1.362 +		[Test()]
   1.363 +		public void TestAddingUnitTypeRequirementWithNoNumberDefaultsToHavingOne()
   1.364 +		{
   1.365 +			Army army = new Army(mockRace, "Test", 1000);
   1.366 +			AddUnitOfTypeToArmy(unitType2, army);
   1.367 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.368 +			req.AddUnitTypeRequirement(unitType2);
   1.369 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.370 +		}
   1.371 +
   1.372 +		[Test()]
   1.373 +		public void TestAddingUnitTypeMakesRequirementPass()
   1.374 +		{
   1.375 +			Army army = new Army(mockRace, "Test", 1000);
   1.376 +			AddUnitOfTypeToArmy(unitType2, army);
   1.377 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.378 +			req.AddUnitTypeRequirement(unitType2, 2);
   1.379 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
   1.380 +			AddUnitOfTypeToArmy(unitType2, army);
   1.381 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
   1.382 +		}
   1.383 +
   1.384 +		[Test()]
   1.385 +		public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
   1.386 +		{
   1.387 +			Army army = new Army(mockRace, "Test", 1000);
   1.388 +			AddUnitOfTypeToArmy(unitType1, army);
   1.389 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.390 +			req.AddUnitTypeRequirement(unitType2);
   1.391 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   1.392 +		}
   1.393 +
   1.394 +		[Test()]
   1.395 +		public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
   1.396 +		{
   1.397 +			Army army = new Army(mockRace, "Test", 1000);
   1.398 +			AddUnitOfTypeToArmy(unitType2, army);
   1.399 +			AddUnitOfTypeToArmy(unitType1, army);
   1.400 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.401 +			req.AddUnitTypeRequirement(unitType2);
   1.402 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   1.403 +		}
   1.404 +
   1.405 +		[Test()]
   1.406 +		public void TestValidityOfArmyWhenNoRequireeAndRequirementNotMet()
   1.407 +		{
   1.408 +			Army army = new Army(mockRace, "Test", 1000);
   1.409 +			AddUnitOfTypeToArmy(unitType2, army);
   1.410 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.411 +			req.AddUnitTypeRequirement(unitType2, 2);
   1.412 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
   1.413 +		}
   1.414 +
   1.415 +		[Test]
   1.416 +		public void TestSatisfyingRequirementChangesResult()
   1.417 +		{
   1.418 +			Army army = new Army(mockRace, "Test", 1000);
   1.419 +			AddUnitOfTypeToArmy(unitType1, army);
   1.420 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.421 +			req.AddUnitTypeRequirement(unitType2);
   1.422 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
   1.423 +			AddUnitOfTypeToArmy(unitType2, army);
   1.424 +			Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
   1.425 +		}
   1.426 +
   1.427 +		[Test]
   1.428 +		public void TestAddingMinNumberUnitTypePassesRequirement()
   1.429 +		{
   1.430 +			Army army = new Army(mockRace, "Test", 1000);
   1.431 +			AddUnitOfTypeToArmy(unitType1, army);
   1.432 +			RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
   1.433 +			req.AddUnitTypeRequirement(unitType2, 2);
   1.434 +			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
   1.435 +			AddUnitOfTypeToArmy(unitType2, army);
   1.436 +			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
   1.437 +		}
   1.438 +
   1.439 +
   1.440 +		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
   1.441 +		{
   1.442 +			army.AddUnit(CreateUnitOfType(unitType, army));
   1.443 +		}
   1.444 +
   1.445 +
   1.446 +		private static Unit CreateUnitOfType(UnitType unitType, Army army)
   1.447 +		{
   1.448 +			return new Unit(unitType, army.GetCategory(unitType.MainCategory));
   1.449 +		}
   1.450 +	}
   1.451 +}
   1.452 +