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 diff
     1.1 --- a/API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs	Sat Jul 02 15:00:16 2011 +0000
     1.2 +++ b/API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs	Sat Jul 02 15:09:48 2011 +0000
     1.3 @@ -16,8 +16,8 @@
     1.4  		private static Race race;
     1.5  		private static string typeID1 = "unit1";
     1.6  		private static string typeID2 = "unit2";
     1.7 -		private UnitType unitType1;
     1.8 -		private UnitType unitType2;
     1.9 +		private static UnitType unitType1;
    1.10 +		private static UnitType unitType2;
    1.11  
    1.12  		[TestFixtureSetUp()]
    1.13  		public void Setup()
    1.14 @@ -107,13 +107,22 @@
    1.15  		}
    1.16  
    1.17  		[Test()]
    1.18 -		[ExpectedException()]
    1.19 -		public void TestCreatesCorrectRequirementForInvalidID()
    1.20 +		[ExpectedException(typeof(InvalidRequirementException), "Invalid unit type 'fibble' for 'Requires at least N units' requirement")]
    1.21 +		public void TestExceptionsForInvalidID()
    1.22  		{
    1.23  			UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory();
    1.24  			UnitType unitType = new UnitType("testUnit", "Test Unit", race);
    1.25  			factory.CreateRequirement(unitType, "fibble");
    1.26  		}
    1.27 +
    1.28 +		[Test()]
    1.29 +		[ExpectedException(typeof(InvalidRequirementException), "Invalid amount 'a' for unit type 'unit1' for 'Requires at least N units' requirement")]
    1.30 +		public void TestExceptionsForInvalidNumber()
    1.31 +		{
    1.32 +			UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory();
    1.33 +			UnitType unitType = new UnitType("testUnit", "Test Unit", race);
    1.34 +			factory.CreateRequirement(unitType, typeID1+":a");
    1.35 +		}
    1.36  	}
    1.37  }
    1.38