changeset 136:d28c3c1ec1ec

Re #27: Unit requirements * Make sure that units return their limits as requirements on the army
author IBBoard <dev@ibboard.co.uk>
date Mon, 25 Apr 2011 15:09:54 +0000
parents 8c3bba80a25e
children 081b48413f6d
files API/Objects/UnitTypeTest.cs
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/UnitTypeTest.cs	Mon Apr 25 10:31:49 2011 +0000
     1.2 +++ b/API/Objects/UnitTypeTest.cs	Mon Apr 25 15:09:54 2011 +0000
     1.3 @@ -55,6 +55,21 @@
     1.4  			unitType.AddRequirement(req);
     1.5  			Assert.That(unitType.GetRequirements(), Has.Length(1));
     1.6  		}
     1.7 +
     1.8 +		[Test]
     1.9 +		public void TestGetRequirementsGetsUnitCountRequirements()
    1.10 +		{
    1.11 +			UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace());
    1.12 +			unitType.MinNumber = 1;
    1.13 +			unitType.MaxNumber = 2;
    1.14 +			Assert.That(unitType.GetRequirements(), Has.Length(2));
    1.15 +			RequiresNoMoreThanNOfUnitTypeRequirement maxLimit = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.16 +			maxLimit.AddUnitTypeRequirement(unitType, 2);
    1.17 +			Assert.That(unitType.GetRequirements(), Has.Member(maxLimit));
    1.18 +			RequiresAtLeastNUnitsRequirement minLimit = new RequiresAtLeastNUnitsRequirement();
    1.19 +			minLimit.AddUnitTypeRequirement(unitType, 1);
    1.20 +			Assert.That(unitType.GetRequirements(), Has.Member(minLimit));
    1.21 +		}
    1.22  	}
    1.23  }
    1.24