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 wrap: on
line diff
--- a/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Sat Mar 31 15:24:41 2012 +0100
+++ b/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Sat Mar 31 20:17:44 2012 +0100
@@ -494,7 +494,9 @@
 			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 4 for 3).");
 			AddUnitOfTypeToArmy(unitType2, army);
 			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 5 for 3).");
-			AddUnitsOfTypeToArmy(3, unitType2, army);
+			AddUnitOfTypeToArmy(unitType2, army);
+			Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 6 for 3).");
+			AddUnitsOfTypeToArmy(2, unitType2, army);
 			Assert_That__PassesAdding(req, unitType1, army);
 		}
 
@@ -515,7 +517,9 @@
 			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 4 for 3).");
 			AddUnitOfTypeToArmy(unitType2, army);
 			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 5 for 3).");
-			AddUnitsOfTypeToArmy(3, unitType2, army);
+			AddUnitOfTypeToArmy(unitType2, army);
+			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 6 for 3).");
+			AddUnitsOfTypeToArmy(2, unitType2, army);
 			Assert_That__ValidationPasses(req, army);
 		}
 
@@ -536,7 +540,9 @@
 			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).");
 			AddUnitOfTypeToArmy(unitType2, army);
 			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).");
-			AddUnitsOfTypeToArmy(3, unitType2, army);
+			AddUnitOfTypeToArmy(unitType2, army);
+			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).");
+			AddUnitsOfTypeToArmy(2, unitType2, army);
 			Assert_That__PassesAdding(req, unitType1, army);
 		}
 
@@ -558,7 +564,9 @@
 			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 4 for 3).");
 			AddUnitOfTypeToArmy(unitType2, army);
 			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 5 for 3).");
-			AddUnitsOfTypeToArmy(3, unitType2, army);
+			AddUnitOfTypeToArmy(unitType2, army);
+			Assert_That__ValidationFails(req, army, "Army must contain: 4 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 6 for 3).");
+			AddUnitsOfTypeToArmy(2, unitType2, army);
 			Assert_That__ValidationPasses(req, army);
 		}