changeset 117:a52cce66eb07

Re #27: Unit requirements * Switch to using validation enum * Add tests for unit type
author IBBoard <dev@ibboard.co.uk>
date Mon, 04 Apr 2011 19:29:24 +0000
parents 49fb69ea13f2
children 1fccac6f8f99
files API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:05:47 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:29:24 2011 +0000
     1.3 @@ -34,7 +34,7 @@
     1.4  			Army army = new Army(mockRace, "Test", 1000);
     1.5  			Unit unit = CreateUnitOfType(unitType1, army);
     1.6  			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
     1.7 -			Assert.That(req.AllowsAdding(unit, army), Is.True);
     1.8 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
     1.9  		}
    1.10  
    1.11  		[Test()]
    1.12 @@ -44,7 +44,24 @@
    1.13  			AddUnitOfTypeToArmy(unitType2, army);
    1.14  			Unit unit = CreateUnitOfType(unitType1, army);
    1.15  			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
    1.16 -			Assert.That(req.AllowsAdding(unit, army), Is.False);
    1.17 +			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
    1.18 +		}
    1.19 +
    1.20 +		[Test()]
    1.21 +		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
    1.22 +		{
    1.23 +			Army army = new Army(mockRace, "Test", 1000);
    1.24 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
    1.25 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.26 +		}
    1.27 +
    1.28 +		[Test()]
    1.29 +		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
    1.30 +		{
    1.31 +			Army army = new Army(mockRace, "Test", 1000);
    1.32 +			AddUnitOfTypeToArmy(unitType2, army);
    1.33 +			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
    1.34 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.35  		}
    1.36  
    1.37  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)