changeset 209:fc9a90d29ae0

Re #379: Fix validation of requirements to check for unit * Fix some of the copy-and-paste errors in the tests - some tests still fail
author IBBoard <dev@ibboard.co.uk>
date Wed, 22 Feb 2012 21:00:01 +0000
parents c323770e61c2
children 649759343da5
files API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs
diffstat 1 files changed, 18 insertions(+), 17 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Wed Feb 22 20:48:40 2012 +0000
     1.2 +++ b/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs	Wed Feb 22 21:00:01 2012 +0000
     1.3 @@ -93,23 +93,24 @@
     1.4  		public void TestAddingUnitTriggersFailure()
     1.5  		{
     1.6  			Army army = new Army(mockRace, "Test", 1000);
     1.7 -			AddUnitOfTypeToArmy(unitType2, army);
     1.8 +			AddUnitOfTypeToArmy(unitType1, army);
     1.9  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.10  			req.AddUnitTypeRequirement(unitType2, 1);
    1.11 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.12 +			AddUnitOfTypeToArmy(unitType2, army);
    1.13  			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.14 -			AddUnitOfTypeToArmy(unitType2, army);
    1.15 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.16  		}
    1.17  
    1.18  		[Test()]
    1.19 -		public void TestAddingUnitTypeDefaultsToNoMoreThanZero()
    1.20 +		public void TestAddingUnitTypeDefaultsToOne()
    1.21  		{
    1.22  			Army army = new Army(mockRace, "Test", 1000);
    1.23 +			AddUnitOfTypeToArmy(unitType1, army);
    1.24  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.25  			req.AddUnitTypeRequirement(unitType2);
    1.26 +			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.27 +			AddUnitOfTypeToArmy(unitType2, army);
    1.28  			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
    1.29 -			AddUnitOfTypeToArmy(unitType2, army);
    1.30 -			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
    1.31  		}
    1.32  
    1.33  		[Test]
    1.34 @@ -141,7 +142,7 @@
    1.35  			AddUnitOfTypeToArmy(unitType1, army);
    1.36  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.37  			req.AddUnitTypeRequirement(unitType2);
    1.38 -			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
    1.39 +			Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
    1.40  		}
    1.41  
    1.42  		[Test]
    1.43 @@ -161,7 +162,7 @@
    1.44  			AddUnitOfTypeToArmy(unitType2, army);
    1.45  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.46  			req.AddUnitTypeRequirement(unitType2);
    1.47 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (have 1)."));
    1.48 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (have 1)."));
    1.49  		}
    1.50  
    1.51  		[Test]
    1.52 @@ -174,7 +175,7 @@
    1.53  			AddUnitOfTypeToArmy(unitType2, army);
    1.54  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.55  			req.AddUnitTypeRequirement(unitType2, 2);
    1.56 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 2 × " + unitType2.Name + " (have 3)."));
    1.57 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every " + unitType1.Name + " (have 3)."));
    1.58  		}
    1.59  
    1.60  		[Test]
    1.61 @@ -186,7 +187,7 @@
    1.62  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.63  			req.AddUnitTypeRequirement(unitType2);
    1.64  			req.AddUnitTypeRequirement(unitType3);
    1.65 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (have 1)."));
    1.66 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."));
    1.67  		}
    1.68  
    1.69  		[Test]
    1.70 @@ -198,7 +199,7 @@
    1.71  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.72  			req.AddUnitTypeRequirement(unitType2);
    1.73  			req.AddUnitTypeRequirement(unitType3);
    1.74 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType3.Name + " (have 1)."));
    1.75 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."));
    1.76  		}
    1.77  
    1.78  		[Test]
    1.79 @@ -211,7 +212,7 @@
    1.80  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.81  			req.AddUnitTypeRequirement(unitType2);
    1.82  			req.AddUnitTypeRequirement(unitType3);
    1.83 -			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (have 1); 0 × " + unitType3.Name + " (have 1)."));
    1.84 +			Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (have 1); 0 × " + unitType3.Name + " for every " + unitType1.Name + " (have 1)."));
    1.85  		}
    1.86  
    1.87  		[Test]
    1.88 @@ -230,7 +231,7 @@
    1.89  			AddUnitOfTypeToArmy(unitType1, army);
    1.90  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
    1.91  			req.AddUnitTypeRequirement(unitType2);
    1.92 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (would have 1)."));
    1.93 +			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 1)."));
    1.94  		}
    1.95  
    1.96  		[Test]
    1.97 @@ -242,7 +243,7 @@
    1.98  			AddUnitOfTypeToArmy(unitType2, army);
    1.99  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.100  			req.AddUnitTypeRequirement(unitType2, 2);
   1.101 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army cannot contain more than: 2 × " + unitType2.Name + " (would have 3)."));
   1.102 +			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 3)."));
   1.103  		}
   1.104  
   1.105  		[Test]
   1.106 @@ -253,7 +254,7 @@
   1.107  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.108  			req.AddUnitTypeRequirement(unitType2);
   1.109  			req.AddUnitTypeRequirement(unitType3);
   1.110 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (would have 1)."));
   1.111 +			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."));
   1.112  		}
   1.113  
   1.114  		[Test]
   1.115 @@ -265,7 +266,7 @@
   1.116  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.117  			req.AddUnitTypeRequirement(unitType2);
   1.118  			req.AddUnitTypeRequirement(unitType3);
   1.119 -			Assert.That(req.GetAllowsAddingMessage(unitType3, army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (would have 1); 0 × " + unitType3.Name + " (would have 1)."));
   1.120 +			Assert.That(req.GetAllowsAddingMessage(unitType3, army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 1); 0 × " + unitType3.Name + " for every " + unitType1.Name + " (would have 1)."));
   1.121  		}
   1.122  
   1.123  		[Test]
   1.124 @@ -277,7 +278,7 @@
   1.125  			UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
   1.126  			req.AddUnitTypeRequirement(unitType2);
   1.127  			req.AddUnitTypeRequirement(unitType3);
   1.128 -			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (would have 1); 0 × " + unitType3.Name + " (would have 1)."));
   1.129 +			Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 1); 0 × " + unitType3.Name + " for every " + unitType1.Name + " (would have 1)."));
   1.130  		}
   1.131  
   1.132  		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)