Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 194:f1f4df654a91
Re #350: Add requirement to allow N of unit for specific other units
* Add tests for defining minimum amount as well as allowed amount (e.g. "2 of these allow 3 of those")
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 03 Dec 2011 19:56:58 +0000 |
parents | cf1c0a91eaa9 |
children | 8e95ccb8e9d5 |
files | API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactoryTest.cs |
diffstat | 1 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactoryTest.cs Sat Dec 03 16:53:36 2011 +0000 +++ b/API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactoryTest.cs Sat Dec 03 19:56:58 2011 +0000 @@ -73,6 +73,17 @@ } [Test()] + public void TestCreatesCorrectRequirementWithTwoNumbers() + { + UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory(); + UnitType unitType = new UnitType("testUnit", "Test Unit", race); + RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType); + expectedReq.AddUnitTypeRequirement(unitType1, 2, 3); + IRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2;3", raceFactory); + Assert.That(req, Is.EqualTo(expectedReq)); + } + + [Test()] public void TestCreatesCorrectRequirementForTwoIDsWithTwoNumbers() { UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory(); @@ -118,13 +129,31 @@ } [Test()] - [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid amount 'a' for unit type 'unit1' for 'Requires N units for M units' requirement")] + [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit type 'unit1' for 'Requires N units for M units' requirement")] public void TestExceptionsForInvalidNumber() { UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory(); UnitType unitType = new UnitType("testUnit", "Test Unit", race); factory.CreateRequirement(unitType, typeID1+":a", raceFactory); } + + [Test()] + [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit type 'unit1' for 'Requires N units for M units' requirement")] + public void TestExceptionsForInvalidAllowedNumber() + { + UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory(); + UnitType unitType = new UnitType("testUnit", "Test Unit", race); + factory.CreateRequirement(unitType, typeID1 + ":3;a", raceFactory); + } + + [Test()] + [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid minimum amount 'a' for unit type 'unit1' for 'Requires N units for M units' requirement")] + public void TestExceptionsForInvalidMinimumNumber() + { + UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory(); + UnitType unitType = new UnitType("testUnit", "Test Unit", race); + factory.CreateRequirement(unitType, typeID1 + ":a;3", raceFactory); + } } }