changeset 223:fd51527f6d64

Re #395: Requirements can incorrectly allow based on common divisor * Test for 3 given 6 (which would give the 1:2 ratio but not the 2:4 ratio)
author IBBoard <dev@ibboard.co.uk>
date Sat, 31 Mar 2012 20:17:44 +0100
parents 12ac487af0ba
children 49480e1a8f90
files API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Sat Mar 31 15:24:41 2012 +0100
     1.2 +++ b/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Sat Mar 31 20:17:44 2012 +0100
     1.3 @@ -494,7 +494,9 @@
     1.4  			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 4 for 3).");
     1.5  			AddUnitOfTypeToArmy(unitType2, army);
     1.6  			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 5 for 3).");
     1.7 -			AddUnitsOfTypeToArmy(3, unitType2, army);
     1.8 +			AddUnitOfTypeToArmy(unitType2, army);
     1.9 +			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 6 for 3).");
    1.10 +			AddUnitsOfTypeToArmy(2, unitType2, army);
    1.11  			Assert_That__PassesAdding(req, unitType1, army);
    1.12  		}
    1.13  
    1.14 @@ -515,7 +517,9 @@
    1.15  			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 4 for 3).");
    1.16  			AddUnitOfTypeToArmy(unitType2, army);
    1.17  			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 5 for 3).");
    1.18 -			AddUnitsOfTypeToArmy(3, unitType2, army);
    1.19 +			AddUnitOfTypeToArmy(unitType2, army);
    1.20 +			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 6 for 3).");
    1.21 +			AddUnitsOfTypeToArmy(2, unitType2, army);
    1.22  			Assert_That__ValidationPasses(req, army);
    1.23  		}
    1.24  
    1.25 @@ -536,7 +540,9 @@
    1.26  			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (would have 4 for 3).");
    1.27  			AddUnitOfTypeToArmy(unitType2, army);
    1.28  			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (would have 5 for 3).");
    1.29 -			AddUnitsOfTypeToArmy(3, unitType2, army);
    1.30 +			AddUnitOfTypeToArmy(unitType2, army);
    1.31 +			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (would have 6 for 3).");
    1.32 +			AddUnitsOfTypeToArmy(2, unitType2, army);
    1.33  			Assert_That__PassesAdding(req, unitType1, army);
    1.34  		}
    1.35  
    1.36 @@ -558,7 +564,9 @@
    1.37  			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 4 for 3).");
    1.38  			AddUnitOfTypeToArmy(unitType2, army);
    1.39  			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 5 for 3).");
    1.40 -			AddUnitsOfTypeToArmy(3, unitType2, army);
    1.41 +			AddUnitOfTypeToArmy(unitType2, army);
    1.42 +			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 6 for 3).");
    1.43 +			AddUnitsOfTypeToArmy(2, unitType2, army);
    1.44  			Assert_That__ValidationPasses(req, army);
    1.45  		}
    1.46