Mercurial > repos > IBBoard.WarFoundry.API.Tests
diff API/Objects/Requirement/RequiresNUnitsForMUnitsRequirementTest.cs @ 207:27f163bf884a
Re #379: Fix validation of requirements to check for unit
* Update checked text to match new, cleaner text
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 31 Jan 2012 20:59:15 +0000 |
parents | 49e50238c380 |
children |
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresNUnitsForMUnitsRequirementTest.cs Sun Jan 29 20:03:44 2012 +0000 +++ b/API/Objects/Requirement/RequiresNUnitsForMUnitsRequirementTest.cs Tue Jan 31 20:59:15 2012 +0000 @@ -62,7 +62,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 "+unitType2.Name+" for every 1 "+unitType1.Name + " (would have 0 for 1).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).")); } [Test()] @@ -75,7 +75,7 @@ req.AddUnitTypeRequirement(unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (would have 0 for 1).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).")); } [Test()] @@ -87,7 +87,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (would have 1 for 2).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).")); } [Test()] @@ -115,7 +115,7 @@ req.AddUnitTypeRequirement(unitType3, 1, 1); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (would have 1 for 2).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).")); } [Test()] @@ -130,7 +130,7 @@ req.AddUnitTypeRequirement(unitType3, 1, 1); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (would have 1 for 2); 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (would have 1 for 2).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).")); } [Test()] @@ -143,7 +143,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2, unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (would have 1 for 2); 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (would have 1 for 2).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2).")); } [Test()] @@ -157,7 +157,7 @@ req.AddUnitTypeRequirement(unitType2, 1, 2); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 2 " + unitType1.Name + " (would have 1 for 3).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (would have 1 for 3).")); } [Test()] @@ -169,7 +169,7 @@ req.AddUnitTypeRequirement(unitType2, 2, 3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 " + unitType2.Name + " for every 3 " + unitType1.Name + " (would have 1 for 1).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (would have 1 for 1).")); } [Test()] @@ -182,7 +182,7 @@ req.AddUnitTypeRequirement(unitType2, 2, 3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 " + unitType2.Name + " for every 3 " + unitType1.Name + " (would have 1 for 2).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (would have 1 for 2).")); } [Test()] @@ -195,7 +195,7 @@ req.AddUnitTypeRequirement(unitType2, 2, 3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 " + unitType2.Name + " for every 3 " + unitType1.Name + " (would have 3 for 4).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (would have 3 for 4).")); } [Test()] @@ -287,7 +287,7 @@ req.AddUnitTypeRequirement(unitType2, unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 1 " + unitType1.Name + " (would have 2 for 3).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 2 for 3).")); } [Test()] @@ -302,7 +302,7 @@ req.AddUnitTypeRequirement(unitType2, unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 1 " + unitType1.Name + " (would have 2 for 3).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 2 for 3).")); } [Test()] @@ -317,7 +317,7 @@ req.AddUnitTypeRequirement(unitType2, unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 1 " + unitType1.Name + " (would have 2 for 3).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 2 for 3).")); } [Test()] @@ -408,7 +408,7 @@ req.AddUnitTypeRequirement(3, unitType2, unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (would have 2 for 7).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (would have 2 for 7).")); } [Test()] @@ -421,7 +421,7 @@ req.AddUnitTypeRequirement(3, unitType2, unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (would have 2 for 7).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (would have 2 for 7).")); } [Test()] @@ -434,7 +434,7 @@ req.AddUnitTypeRequirement(3, unitType2, unitType3); Unit unit = CreateUnitOfType(unitType1, army); Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (would have 2 for 7).")); + Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (would have 2 for 7).")); } [Test()] @@ -464,7 +464,7 @@ AddUnitOfTypeToArmy(unitType1, army); RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 0 for 1).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1).")); } [Test()] @@ -477,7 +477,7 @@ req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (have 0 for 1).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1).")); } [Test()] @@ -489,7 +489,7 @@ AddUnitOfTypeToArmy(unitType1, army); RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 1 for 2).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).")); } [Test()] @@ -517,7 +517,7 @@ req.AddUnitTypeRequirement(unitType2, 1, 2); req.AddUnitTypeRequirement(unitType3, 1, 1); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (have 1 for 2).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).")); } [Test()] @@ -532,7 +532,7 @@ req.AddUnitTypeRequirement(unitType2, 1, 1); req.AddUnitTypeRequirement(unitType3, 1, 1); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 1 for 2); 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (have 1 for 2).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).")); } [Test()] @@ -545,7 +545,7 @@ AddUnitOfTypeToArmy(unitType1, army); RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2, unitType3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 1 for 2); 1 " + unitType3.Name + " for every 1 " + unitType1.Name + " (have 1 for 2).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2); 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).")); } [Test()] @@ -557,7 +557,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2, 3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 " + unitType2.Name + " for every 3 " + unitType1.Name + " (have 1 for 1).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (have 1 for 1).")); } [Test()] @@ -569,7 +569,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2, 3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 " + unitType2.Name + " for every 3 " + unitType1.Name + " (have 1 for 2).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (have 1 for 2).")); } [Test()] @@ -581,7 +581,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2, 3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 " + unitType2.Name + " for every 3 " + unitType1.Name + " (have 3 for 4).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every 3 × " + unitType1.Name + " (have 3 for 4).")); } [Test()] @@ -595,7 +595,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1, 2); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 2 " + unitType1.Name + " (have 1 for 3).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 2 × " + unitType1.Name + " (have 1 for 3).")); } [Test()] @@ -680,7 +680,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(3, unitType2, unitType3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (have 2 for 7).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (have 2 for 7).")); } [Test()] @@ -692,7 +692,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(3, unitType2, unitType3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (have 2 for 7).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (have 2 for 7).")); } [Test()] @@ -704,7 +704,7 @@ RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(3, unitType2, unitType3); Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " or " + unitType3.Name + " for every 3 " + unitType1.Name + " (have 2 for 7).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 3 × " + unitType1.Name + " (have 2 for 7).")); } private static void AddUnitsOfTypeToArmy(int count, UnitType unitType, Army army) @@ -725,21 +725,21 @@ return new Unit(unitType, army.GetCategory(unitType.MainCategory)); } - public override RequiresNUnitsForMUnitsRequirement GetObject() + public override RequiresNUnitsForMUnitsRequirement GetObject() { RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3); req.AddUnitTypeRequirement(unitType1, 2, 3); return req; } - public override RequiresNUnitsForMUnitsRequirement GetSameObject() + public override RequiresNUnitsForMUnitsRequirement GetSameObject() { RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3); req.AddUnitTypeRequirement(unitType1, 2, 3); return req; } - public override RequiresNUnitsForMUnitsRequirement GetDifferentObject() + public override RequiresNUnitsForMUnitsRequirement GetDifferentObject() { RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3); DummyWarFoundryFactory factory = new DummyWarFoundryFactory();