Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 116:49fb69ea13f2
Re #27: Unit requirements
* Switch to enumeration and update tests as appropriate
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 04 Apr 2011 19:05:47 +0000 |
parents | bcca07bee8ea |
children | a52cce66eb07 |
files | API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs API/Objects/Requirement/ValidationTests.cs |
diffstat | 3 files changed, 30 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs Sun Apr 03 19:40:06 2011 +0000 +++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs Mon Apr 04 19:05:47 2011 +0000 @@ -34,7 +34,7 @@ Army army = new Army(mockRace, "Test", 1000); Unit unit = CreateUnitOfType(unitType1, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); - Assert.That(req.AllowsAdding(unit, army), Is.False); + Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -44,7 +44,7 @@ AddUnitOfTypeToArmy(unitType2, army); Unit unit = CreateUnitOfType(unitType1, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); - Assert.That(req.AllowsAdding(unit, army), Is.True); + Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -52,7 +52,7 @@ { Army army = new Army(mockRace, "Test", 1000); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -61,7 +61,7 @@ Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -69,7 +69,7 @@ { Army army = new Army(mockRace, "Test", 1000); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -78,7 +78,7 @@ Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -88,7 +88,7 @@ AddUnitOfTypeToArmy(unitType2, army); AddUnitOfTypeToArmy(unitType3, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -98,7 +98,7 @@ AddUnitOfTypeToArmy(unitType2, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -109,7 +109,7 @@ AddUnitOfTypeToArmy(unitType2, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -119,7 +119,7 @@ AddUnitOfTypeToArmy(unitType2, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -127,7 +127,7 @@ { Army army = new Army(mockRace, "Test", 1000); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); - Assert.That(req.ValidatesArmy(army), Is.False); + Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -136,7 +136,7 @@ Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2); - Assert.That(req.ValidatesArmy(army), Is.True); + Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed)); } private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
--- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs Sun Apr 03 19:40:06 2011 +0000 +++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs Mon Apr 04 19:05:47 2011 +0000 @@ -35,7 +35,7 @@ Unit unit = CreateUnitOfType(unitType1, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unit, army), Is.False); + Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -46,7 +46,7 @@ Unit unit = CreateUnitOfType(unitType1, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unit, army), Is.True); + Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -55,7 +55,7 @@ Army army = new Army(mockRace, "Test", 1000); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -65,7 +65,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -75,7 +75,7 @@ UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -86,7 +86,7 @@ UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -98,7 +98,7 @@ UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); req.AddUnitTypeRequirement(unitType3); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -108,7 +108,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.AllowsAdding(unitType1, army), Is.False); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -118,7 +118,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.AllowsAdding(unitType3, army), Is.True); + Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable)); } [Test()] @@ -129,7 +129,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -139,7 +139,7 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.AllowsAdding(unitType1, army), Is.True); + Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -149,7 +149,7 @@ AddUnitOfTypeToArmy(unitType1, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.ValidatesArmy(army), Is.False); + Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); } [Test()] @@ -160,7 +160,7 @@ AddUnitOfTypeToArmy(unitType1, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); - Assert.That(req.ValidatesArmy(army), Is.True); + Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed)); } [Test()] @@ -170,13 +170,16 @@ AddUnitOfTypeToArmy(unitType2, army); UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2); - Assert.That(req.ValidatesArmy(army), Is.True); + Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable)); } + private static void AddUnitOfTypeToArmy(UnitType unitType, Army army) { army.AddUnit(CreateUnitOfType(unitType, army)); } + + private static Unit CreateUnitOfType(UnitType unitType, Army army) { return new Unit(unitType, army.GetCategory(unitType.MainCategory));
--- a/API/Objects/Requirement/ValidationTests.cs Sun Apr 03 19:40:06 2011 +0000 +++ b/API/Objects/Requirement/ValidationTests.cs Mon Apr 04 19:05:47 2011 +0000 @@ -43,7 +43,7 @@ Assert.That(Validates.AsOkay(Validation.Failed), Is.False); } - public void TestValidatesAsNotOkaySuccedesForPassedAndNA() + public void TestValidatesAsNotOkaySuccedesForFailedAndNA() { Assert.That(Validates.AsNotOkay(Validation.Failed), Is.True); Assert.That(Validates.AsNotOkay(Validation.NotApplicable), Is.True);