changeset 121:6f46fa3c47e5

Re #27: Unit requirements * Test threshold * Test that default setting is 0 * Test that "No more than" requirement gives "N/A" when appropriate
author IBBoard <dev@ibboard.co.uk>
date Sat, 09 Apr 2011 10:18:27 +0000
parents d186d46f0bae
children aa37b31976e6
files API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirementTest.cs
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Wed Apr 06 20:05:04 2011 +0000
     1.2 +++ b/API/Objects/Requirement/UnitRequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Sat Apr 09 10:18:27 2011 +0000
     1.3 @@ -90,15 +90,38 @@
     1.4  		}
     1.5  
     1.6  		[Test()]
     1.7 +		public void TestAddingUnitTriggersFailure()
     1.8 +		{
     1.9 +			Army army = new Army(mockRace, "Test", 1000);
    1.10 +			AddUnitOfTypeToArmy(unitType2, army);
    1.11 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    1.12 +			req.AddUnitTypeRequirement(unitType2, 1);
    1.13 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.14 +			AddUnitOfTypeToArmy(unitType2, army);
    1.15 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.16 +		}
    1.17 +
    1.18 +		[Test()]
    1.19  		public void TestAddingUnitTypeDefaultsToNoMoreThanZero()
    1.20  		{
    1.21  			Army army = new Army(mockRace, "Test", 1000);
    1.22  			AddUnitOfTypeToArmy(unitType2, army);
    1.23  			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    1.24 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.25  			req.AddUnitTypeRequirement(unitType2);
    1.26  			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.27  		}
    1.28  
    1.29 +		[Test]
    1.30 +		public void TestRequirementNotApplicableWhenLimitedUnitNotIncluded()
    1.31 +		{
    1.32 +			Army army = new Army(mockRace, "Test", 1000);
    1.33 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    1.34 +			req.AddUnitTypeRequirement(unitType2);
    1.35 +			Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable));
    1.36 +			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.NotApplicable));
    1.37 +		}
    1.38 +
    1.39  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
    1.40  		{
    1.41  			army.AddUnit(CreateUnitOfType(unitType, army));