Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 106:4dad874f4862
Re #27: Define unit requirements
* Add unit tests for multiple unit types being required
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 27 Mar 2011 19:19:04 +0000 |
parents | 9163bd04a3db |
children | e2ea6562ef08 |
files | API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs |
diffstat | 1 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs Sun Mar 27 19:15:22 2011 +0000 +++ b/API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs Sun Mar 27 19:19:04 2011 +0000 @@ -14,6 +14,7 @@ private MockRace mockRace; private UnitType unitType1; private UnitType unitType2; + private UnitType unitType3; [TestFixtureSetUp()] public void SetupRace() @@ -23,6 +24,8 @@ mockRace.AddUnitType(unitType1); unitType2 = new MockUnitType("type2", "Unit Type 2"); mockRace.AddUnitType(unitType2); + unitType3 = new MockUnitType("type3", "Unit Type 3"); + mockRace.AddUnitType(unitType3); } [Test()] @@ -61,6 +64,33 @@ Assert.That(req.AllowsAdding(unitType1, army), Is.True); } + [Test()] + public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired() + { + Army army = new Army(mockRace, "Test", 1000); + UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2, unitType3); + Assert.That(req.AllowsAdding(unitType1, army), Is.False); + } + + [Test()] + public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired() + { + Army army = new Army(mockRace, "Test", 1000); + AddUnitOfTypeToArmy(unitType2, army); + UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2, unitType3); + Assert.That(req.AllowsAdding(unitType1, army), Is.False); + } + + [Test()] + public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired() + { + Army army = new Army(mockRace, "Test", 1000); + AddUnitOfTypeToArmy(unitType2, army); + AddUnitOfTypeToArmy(unitType3, army); + UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType2, unitType3); + Assert.That(req.AllowsAdding(unitType1, army), Is.True); + } + private static void AddUnitOfTypeToArmy(UnitType unitType, Army army) { army.AddUnit(CreateUnitOfType(unitType, army));