changeset 118:1fccac6f8f99

Re #27: Unit requirements * Test limit setting for "no more than" requirement
author IBBoard <dev@ibboard.co.uk>
date Mon, 04 Apr 2011 19:46:07 +0000
parents a52cce66eb07
children 5f389466e8a8
files API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:29:24 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:46:07 2011 +0000
     1.3 @@ -64,6 +64,37 @@
     1.4  			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
     1.5  		}
     1.6  
     1.7 +		[Test()]
     1.8 +		public void TestAddingUnitTypeSetsLimit()
     1.9 +		{
    1.10 +			Army army = new Army(mockRace, "Test", 1000);
    1.11 +			AddUnitOfTypeToArmy(unitType2, army);
    1.12 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.13 +			req.AddUnitTypeRequirement(unitType2, 1);
    1.14 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.15 +		}
    1.16 +
    1.17 +		[Test()]
    1.18 +		public void TestAddingUnitTypeSetsLimitForFailure()
    1.19 +		{
    1.20 +			Army army = new Army(mockRace, "Test", 1000);
    1.21 +			AddUnitOfTypeToArmy(unitType2, army);
    1.22 +			AddUnitOfTypeToArmy(unitType2, army);
    1.23 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.24 +			req.AddUnitTypeRequirement(unitType2, 1);
    1.25 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.26 +		}
    1.27 +
    1.28 +		[Test()]
    1.29 +		public void TestAddingUnitTypeDefaultsToNoMoreThanZero()
    1.30 +		{
    1.31 +			Army army = new Army(mockRace, "Test", 1000);
    1.32 +			AddUnitOfTypeToArmy(unitType2, army);
    1.33 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
    1.34 +			req.AddUnitTypeRequirement(unitType2);
    1.35 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.36 +		}
    1.37 +
    1.38  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
    1.39  		{
    1.40  			army.AddUnit(CreateUnitOfType(unitType, army));