changeset 235:d122354eeebc

Re #410: N per M models in parent requirement * Add tests for adding * Change text on adding to make more sense (tell users N, M, and how many there are now)
author IBBoard <dev@ibboard.co.uk>
date Wed, 01 Aug 2012 21:01:43 +0100
parents e418ba645d06
children be409428bbea
files API/Objects/Requirement/UnitRequiresNParentModelsForMUnitsRequirementTests.cs
diffstat 1 files changed, 54 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/UnitRequiresNParentModelsForMUnitsRequirementTests.cs	Sun Jul 29 21:05:41 2012 +0100
     1.2 +++ b/API/Objects/Requirement/UnitRequiresNParentModelsForMUnitsRequirementTests.cs	Wed Aug 01 21:01:43 2012 +0100
     1.3 @@ -32,6 +32,28 @@
     1.4  		}
     1.5  		
     1.6  		[Test()]
     1.7 +		public void TestAddingUnitTypeWithParentAndTwoForOneIsAllowed()
     1.8 +		{
     1.9 +			Army army = new Army(mockRace, "Test", 1000);
    1.10 +			Unit parent = AddUnitOfTypeToArmy(unitType2, army);
    1.11 +			UnitRequiresNParentModelsForMUnitsRequirement req = new UnitRequiresNParentModelsForMUnitsRequirement(unitType1);
    1.12 +			req.AddUnitTypeRequirement(unitType2, 2);
    1.13 +			AddUnitOfTypeToArmy(unitType1, army, parent);
    1.14 +			Assert_That__PassesAdding(req, unitType1, parent, army);
    1.15 +		}
    1.16 +		
    1.17 +		[Test()]
    1.18 +		public void TestAddingUnitTypeWithParentAndOneForTwoIsAllowed()
    1.19 +		{
    1.20 +			Army army = new Army(mockRace, "Test", 1000);
    1.21 +			Unit parent = AddUnitOfTypeToArmy(unitType2, army);
    1.22 +			parent.Size = 2;
    1.23 +			UnitRequiresNParentModelsForMUnitsRequirement req = new UnitRequiresNParentModelsForMUnitsRequirement(unitType1);
    1.24 +			req.AddUnitTypeRequirement(unitType2, 1, 2);
    1.25 +			Assert_That__PassesAdding(req, unitType1, parent, army);
    1.26 +		}
    1.27 +		
    1.28 +		[Test()]
    1.29  		public void TestAddingUnitTypeWithWrongParentAndOneUnitTypeRequiredIsNotApplicable()
    1.30  		{
    1.31  			Army army = new Army(mockRace, "Test", 1000);
    1.32 @@ -49,7 +71,34 @@
    1.33  			AddUnitOfTypeToArmy(unitType1, army, parent);
    1.34  			UnitRequiresNParentModelsForMUnitsRequirement req = new UnitRequiresNParentModelsForMUnitsRequirement(unitType1);
    1.35  			req.AddUnitTypeRequirement(unitType3);
    1.36 -			Assert_That__FailsAdding(req, unitType1, parent, army, "Army can only contain 1 × " + unitType1.Name + " as sub-units of each " + unitType3.Name + ", would have 2");
    1.37 +			string msg = String.Format("Units of type {0} can only have {1} x {2} for every {3} models, would have {4} for {5}", unitType3.Name, 1, unitType1.Name, 1, 2, 1);
    1.38 +			Assert_That__FailsAdding(req, unitType1, parent, army, msg);
    1.39 +		}
    1.40 +		
    1.41 +		[Test()]
    1.42 +		public void TestAddingTooManyUnitTypesWithParentAndTwoForOneFails()
    1.43 +		{
    1.44 +			Army army = new Army(mockRace, "Test", 1000);
    1.45 +			Unit parent = AddUnitOfTypeToArmy(unitType3, army);
    1.46 +			AddUnitOfTypeToArmy(unitType1, army, parent);
    1.47 +			AddUnitOfTypeToArmy(unitType1, army, parent);
    1.48 +			UnitRequiresNParentModelsForMUnitsRequirement req = new UnitRequiresNParentModelsForMUnitsRequirement(unitType1);
    1.49 +			req.AddUnitTypeRequirement(unitType3, 2);
    1.50 +			string msg = String.Format("Units of type {0} can only have {1} x {2} for every {3} models, would have {4} for {5}", unitType3.Name, 2, unitType1.Name, 1, 3, 1);
    1.51 +			Assert_That__FailsAdding(req, unitType1, parent, army, msg);
    1.52 +		}
    1.53 +		
    1.54 +		[Test()]
    1.55 +		public void TestAddingTooManyUnitTypesWithParentAndOneForTwoFails()
    1.56 +		{
    1.57 +			Army army = new Army(mockRace, "Test", 1000);
    1.58 +			Unit parent = AddUnitOfTypeToArmy(unitType3, army);
    1.59 +			parent.Size = 2;
    1.60 +			AddUnitOfTypeToArmy(unitType1, army, parent);
    1.61 +			UnitRequiresNParentModelsForMUnitsRequirement req = new UnitRequiresNParentModelsForMUnitsRequirement(unitType1);
    1.62 +			req.AddUnitTypeRequirement(unitType3, 1, 2);
    1.63 +			string msg = String.Format("Units of type {0} can only have {1} x {2} for every {3} models, would have {4} for {5}", unitType3.Name, 1, unitType1.Name, 2, 2, 2);
    1.64 +			Assert_That__FailsAdding(req, unitType1, parent, army, msg);
    1.65  		}
    1.66  		
    1.67  		[Test()]
    1.68 @@ -60,7 +109,8 @@
    1.69  			AddUnitsOfTypeToArmy(5, unitType1, army, parent);
    1.70  			UnitRequiresNParentModelsForMUnitsRequirement req = new UnitRequiresNParentModelsForMUnitsRequirement(unitType1);
    1.71  			req.AddUnitTypeRequirement(unitType2);
    1.72 -			Assert_That__FailsAdding(req, unitType1, parent, army, "Army can only contain 5 × " + unitType1.Name + " as sub-units of each " + unitType2.Name + ", would have 6");
    1.73 +			string msg = String.Format("Units of type {0} can only have {1} x {2} for every {3} models, would have {4} for {5}", unitType2.Name, 1, unitType1.Name, 1, 6, 5);
    1.74 +			Assert_That__FailsAdding(req, unitType1, parent, army, msg);
    1.75  		}
    1.76  		
    1.77  		[Test()]
    1.78 @@ -73,7 +123,8 @@
    1.79  			req.AddUnitTypeRequirement(unitType2);
    1.80  			Assert_That__PassesAdding(req, unitType1, parent, army);
    1.81  			AddUnitOfTypeToArmy(unitType1, army, parent);
    1.82 -			Assert_That__FailsAdding(req, unitType1, parent, army, "Army can only contain 5 × " + unitType1.Name + " as sub-units of each " + unitType2.Name + ", would have 6");
    1.83 +			string msg = String.Format("Units of type {0} can only have {1} x {2} for every {3} models, would have {4} for {5}", unitType2.Name, 1, unitType1.Name, 1, 6, 5);
    1.84 +			Assert_That__FailsAdding(req, unitType1, parent, army, msg);
    1.85  		}
    1.86  
    1.87  		[Test()]