changeset 106:4dad874f4862

Re #27: Define unit requirements * Add unit tests for multiple unit types being required
author IBBoard <dev@ibboard.co.uk>
date Sun, 27 Mar 2011 19:19:04 +0000
parents 9163bd04a3db
children e2ea6562ef08
files API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs	Sun Mar 27 19:15:22 2011 +0000
     1.2 +++ b/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs	Sun Mar 27 19:19:04 2011 +0000
     1.3 @@ -14,6 +14,7 @@
     1.4  		private MockRace mockRace;
     1.5  		private UnitType unitType1;
     1.6  		private UnitType unitType2;
     1.7 +		private UnitType unitType3;
     1.8  
     1.9  		[TestFixtureSetUp()]
    1.10  		public void SetupRace()
    1.11 @@ -23,6 +24,8 @@
    1.12  			mockRace.AddUnitType(unitType1);
    1.13  			unitType2 = new MockUnitType("type2", "Unit Type 2");
    1.14  			mockRace.AddUnitType(unitType2);
    1.15 +			unitType3 = new MockUnitType("type3", "Unit Type 3");
    1.16 +			mockRace.AddUnitType(unitType3);
    1.17  		}
    1.18  
    1.19  		[Test()]
    1.20 @@ -61,6 +64,33 @@
    1.21  			Assert.That(req.AllowsAdding(unitType1, army), Is.True);
    1.22  		}
    1.23  
    1.24 +		[Test()]
    1.25 +		public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
    1.26 +		{
    1.27 +			Army army = new Army(mockRace, "Test", 1000);
    1.28 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2, unitType3);
    1.29 +			Assert.That(req.AllowsAdding(unitType1, army), Is.False);
    1.30 +		}
    1.31 +
    1.32 +		[Test()]
    1.33 +		public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
    1.34 +		{
    1.35 +			Army army = new Army(mockRace, "Test", 1000);
    1.36 +			AddUnitOfTypeToArmy(unitType2, army);
    1.37 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2, unitType3);
    1.38 +			Assert.That(req.AllowsAdding(unitType1, army), Is.False);
    1.39 +		}
    1.40 +
    1.41 +		[Test()]
    1.42 +		public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
    1.43 +		{
    1.44 +			Army army = new Army(mockRace, "Test", 1000);
    1.45 +			AddUnitOfTypeToArmy(unitType2, army);
    1.46 +			AddUnitOfTypeToArmy(unitType3, army);
    1.47 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2, unitType3);
    1.48 +			Assert.That(req.AllowsAdding(unitType1, army), Is.True);
    1.49 +		}
    1.50 +
    1.51  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
    1.52  		{
    1.53  			army.AddUnit(CreateUnitOfType(unitType, army));