Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
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 wrap: on
line diff
--- a/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs Wed Feb 22 20:48:40 2012 +0000 +++ b/API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs Wed Feb 22 21:00:01 2012 +0000 @@ -93,23 +93,24 @@ public void TestAddingUnitTriggersFailure() { Army army = new Army(mockRace, "Test", 1000); - AddUnitOfTypeToArmy(unitType2, army); + AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1); - Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); AddUnitOfTypeToArmy(unitType2, army); - Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] - public void TestAddingUnitTypeDefaultsToNoMoreThanZero() + public void TestAddingUnitTypeDefaultsToOne() { Army army = new Army(mockRace, "Test", 1000); + AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); AddUnitOfTypeToArmy(unitType2, army); - Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test] @@ -141,7 +142,7 @@ AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed)); + Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed)); } [Test] @@ -161,7 +162,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (have 1).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (have 1).")); } [Test] @@ -174,7 +175,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 2 × " + unitType2.Name + " (have 3).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every " + unitType1.Name + " (have 3).")); } [Test] @@ -186,7 +187,7 @@ UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (have 1).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1).")); } [Test] @@ -198,7 +199,7 @@ UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType3.Name + " (have 1).")); + Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1).")); } [Test] @@ -211,7 +212,7 @@ UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (have 1); 0 × " + unitType3.Name + " (have 1).")); + 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).")); } [Test] @@ -230,7 +231,7 @@ AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (would have 1).")); + Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 0 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 1).")); } [Test] @@ -242,7 +243,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army cannot contain more than: 2 × " + unitType2.Name + " (would have 3).")); + Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 2 × " + unitType2.Name + " for every " + unitType1.Name + " (would have 3).")); } [Test] @@ -253,7 +254,7 @@ UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army cannot contain more than: 0 × " + unitType2.Name + " (would have 1).")); + Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army must contain: 1 × " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1).")); } [Test] @@ -265,7 +266,7 @@ UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - 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).")); + 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).")); } [Test] @@ -277,7 +278,7 @@ UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - 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).")); + 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).")); } private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)