changeset 104:782494137b58

Re #27: Define unit requirements * Add tests to cover UnitType, since we'll often be checking if we can create a unit rather than creating and adding it
author IBBoard <dev@ibboard.co.uk>
date Sun, 27 Mar 2011 19:09:02 +0000
parents c6562eb62d04
children 9163bd04a3db
files API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs	Sat Mar 26 21:02:18 2011 +0000
     1.2 +++ b/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs	Sun Mar 27 19:09:02 2011 +0000
     1.3 @@ -26,7 +26,7 @@
     1.4  		}
     1.5  
     1.6  		[Test()]
     1.7 -		public void TestWithNoUnitsAndOneUnitTypeRequired()
     1.8 +		public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequired()
     1.9  		{
    1.10  			Army army = new Army(mockRace, "Test", 1000);
    1.11  			Unit unit = CreateUnitOfType(unitType1, army);
    1.12 @@ -35,7 +35,7 @@
    1.13  		}
    1.14  
    1.15  		[Test()]
    1.16 -		public void TestWithOneUnitAndOneUnitTypeRequired()
    1.17 +		public void TestAddingUnitWithOneUnitAndOneUnitTypeRequired()
    1.18  		{
    1.19  			Army army = new Army(mockRace, "Test", 1000);
    1.20  			AddUnitOfTypeToArmy(unitType2, army);
    1.21 @@ -44,6 +44,23 @@
    1.22  			Assert.That(req.CanAddToArmy(unit, army), Is.True);
    1.23  		}
    1.24  
    1.25 +		[Test()]
    1.26 +		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
    1.27 +		{
    1.28 +			Army army = new Army(mockRace, "Test", 1000);
    1.29 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2);
    1.30 +			Assert.That(req.CanAddToArmy(unitType1, army), Is.False);
    1.31 +		}
    1.32 +
    1.33 +		[Test()]
    1.34 +		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
    1.35 +		{
    1.36 +			Army army = new Army(mockRace, "Test", 1000);
    1.37 +			AddUnitOfTypeToArmy(unitType2, army);
    1.38 +			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2);
    1.39 +			Assert.That(req.CanAddToArmy(unitType1, army), Is.True);
    1.40 +		}
    1.41 +
    1.42  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
    1.43  		{
    1.44  			army.AddUnit(CreateUnitOfType(unitType, army));