changeset 117:a52cce66eb07

Re #27: Unit requirements * Switch to using validation enum * Add tests for unit type
author IBBoard <dev@ibboard.co.uk>
date Mon, 04 Apr 2011 19:29:24 +0000
parents 49fb69ea13f2
children 1fccac6f8f99
files API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:05:47 2011 +0000
+++ b/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:29:24 2011 +0000
@@ -34,7 +34,7 @@
 			Army army = new Army(mockRace, "Test", 1000);
 			Unit unit = CreateUnitOfType(unitType1, army);
 			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
-			Assert.That(req.AllowsAdding(unit, army), Is.True);
+			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
 		}
 
 		[Test()]
@@ -44,7 +44,24 @@
 			AddUnitOfTypeToArmy(unitType2, army);
 			Unit unit = CreateUnitOfType(unitType1, army);
 			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
-			Assert.That(req.AllowsAdding(unit, army), Is.False);
+			Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
+		}
+
+		[Test()]
+		public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredIsAllowed()
+		{
+			Army army = new Army(mockRace, "Test", 1000);
+			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
+			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
+		}
+
+		[Test()]
+		public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredIsNotAllowed()
+		{
+			Army army = new Army(mockRace, "Test", 1000);
+			AddUnitOfTypeToArmy(unitType2, army);
+			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement(unitType2);
+			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
 		}
 
 		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)