Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 153:e84149f37478
Re #351: Add extensible requirement handling method
* Test exception messages
* Test invalid numbers
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 02 Jul 2011 15:09:48 +0000 |
parents | dd283afa5971 |
children | bf2880cf7bc5 |
files | API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs Sat Jul 02 15:00:16 2011 +0000 +++ b/API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs Sat Jul 02 15:09:48 2011 +0000 @@ -16,8 +16,8 @@ private static Race race; private static string typeID1 = "unit1"; private static string typeID2 = "unit2"; - private UnitType unitType1; - private UnitType unitType2; + private static UnitType unitType1; + private static UnitType unitType2; [TestFixtureSetUp()] public void Setup() @@ -107,13 +107,22 @@ } [Test()] - [ExpectedException()] - public void TestCreatesCorrectRequirementForInvalidID() + [ExpectedException(typeof(InvalidRequirementException), "Invalid unit type 'fibble' for 'Requires at least N units' requirement")] + public void TestExceptionsForInvalidID() { UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); UnitType unitType = new UnitType("testUnit", "Test Unit", race); factory.CreateRequirement(unitType, "fibble"); } + + [Test()] + [ExpectedException(typeof(InvalidRequirementException), "Invalid amount 'a' for unit type 'unit1' for 'Requires at least N units' requirement")] + public void TestExceptionsForInvalidNumber() + { + UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); + UnitType unitType = new UnitType("testUnit", "Test Unit", race); + factory.CreateRequirement(unitType, typeID1+":a"); + } } }