Mercurial > repos > IBBoard.WarFoundry.API.Tests
diff API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs @ 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 |
line wrap: on
line diff
--- a/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs Sat Mar 26 21:02:18 2011 +0000 +++ b/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs Sun Mar 27 19:09:02 2011 +0000 @@ -26,7 +26,7 @@ } [Test()] - public void TestWithNoUnitsAndOneUnitTypeRequired() + public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequired() { Army army = new Army(mockRace, "Test", 1000); Unit unit = CreateUnitOfType(unitType1, army); @@ -35,7 +35,7 @@ } [Test()] - public void TestWithOneUnitAndOneUnitTypeRequired() + public void TestAddingUnitWithOneUnitAndOneUnitTypeRequired() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); @@ -44,6 +44,23 @@ Assert.That(req.CanAddToArmy(unit, army), Is.True); } + [Test()] + public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired() + { + Army army = new Army(mockRace, "Test", 1000); + UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2); + Assert.That(req.CanAddToArmy(unitType1, army), Is.False); + } + + [Test()] + public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired() + { + Army army = new Army(mockRace, "Test", 1000); + AddUnitOfTypeToArmy(unitType2, army); + UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2); + Assert.That(req.CanAddToArmy(unitType1, army), Is.True); + } + private static void AddUnitOfTypeToArmy(UnitType unitType, Army army) { army.AddUnit(CreateUnitOfType(unitType, army));