Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 109:f5f66483032a
Re #27: Define unit requirements
* Add unit tests for validating an existing army without adding anything to it
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 28 Mar 2011 19:40:46 +0000 |
parents | 74bfe8b325d6 |
children | 788ef54f5b5a |
files | API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs |
diffstat | 1 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs Sun Mar 27 19:49:51 2011 +0000 +++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs Mon Mar 28 19:40:46 2011 +0000 @@ -102,7 +102,7 @@ } [Test()] - public void TestAddingUnitTypeWithTwoUnitAndTwoOfOneUnitTypeRequired() + public void TestAddingUnitTypeWithTwoUnitsAndTwoOfOneUnitTypeRequired() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); @@ -112,6 +112,23 @@ Assert.That(req.AllowsAdding(unitType1, army), Is.True); } + [Test()] + public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired() + { + Army army = new Army(mockRace, "Test", 1000); + RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); + Assert.That(req.ValidatesArmy(army), Is.False); + } + + [Test()] + public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired() + { + Army army = new Army(mockRace, "Test", 1000); + AddUnitOfTypeToArmy(unitType2, army); + RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); + Assert.That(req.ValidatesArmy(army), Is.True); + } + private static void AddUnitOfTypeToArmy(UnitType unitType, Army army) { army.AddUnit(CreateUnitOfType(unitType, army));