changeset 109:f5f66483032a

Re #27: Define unit requirements * Add unit tests for validating an existing army without adding anything to it
author IBBoard <dev@ibboard.co.uk>
date Mon, 28 Mar 2011 19:40:46 +0000
parents 74bfe8b325d6
children 788ef54f5b5a
files API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs	Sun Mar 27 19:49:51 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs	Mon Mar 28 19:40:46 2011 +0000
     1.3 @@ -102,7 +102,7 @@
     1.4  		}
     1.5  
     1.6  		[Test()]
     1.7 -		public void TestAddingUnitTypeWithTwoUnitAndTwoOfOneUnitTypeRequired()
     1.8 +		public void TestAddingUnitTypeWithTwoUnitsAndTwoOfOneUnitTypeRequired()
     1.9  		{
    1.10  			Army army = new Army(mockRace, "Test", 1000);
    1.11  			AddUnitOfTypeToArmy(unitType2, army);
    1.12 @@ -112,6 +112,23 @@
    1.13  			Assert.That(req.AllowsAdding(unitType1, army), Is.True);
    1.14  		}
    1.15  
    1.16 +		[Test()]
    1.17 +		public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
    1.18 +		{
    1.19 +			Army army = new Army(mockRace, "Test", 1000);
    1.20 +			RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
    1.21 +			Assert.That(req.ValidatesArmy(army), Is.False);
    1.22 +		}
    1.23 +
    1.24 +		[Test()]
    1.25 +		public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
    1.26 +		{
    1.27 +			Army army = new Army(mockRace, "Test", 1000);
    1.28 +			AddUnitOfTypeToArmy(unitType2, army);
    1.29 +			RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
    1.30 +			Assert.That(req.ValidatesArmy(army), Is.True);
    1.31 +		}
    1.32 +
    1.33  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
    1.34  		{
    1.35  			army.AddUnit(CreateUnitOfType(unitType, army));