changeset 118:1fccac6f8f99

Re #27: Unit requirements * Test limit setting for "no more than" requirement
author IBBoard <dev@ibboard.co.uk>
date Mon, 04 Apr 2011 19:46:07 +0000
parents a52cce66eb07
children 5f389466e8a8
files API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:29:24 2011 +0000
+++ b/API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirementTest.cs	Mon Apr 04 19:46:07 2011 +0000
@@ -64,6 +64,37 @@
 			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
 		}
 
+		[Test()]
+		public void TestAddingUnitTypeSetsLimit()
+		{
+			Army army = new Army(mockRace, "Test", 1000);
+			AddUnitOfTypeToArmy(unitType2, army);
+			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
+			req.AddUnitTypeRequirement(unitType2, 1);
+			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
+		}
+
+		[Test()]
+		public void TestAddingUnitTypeSetsLimitForFailure()
+		{
+			Army army = new Army(mockRace, "Test", 1000);
+			AddUnitOfTypeToArmy(unitType2, army);
+			AddUnitOfTypeToArmy(unitType2, army);
+			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
+			req.AddUnitTypeRequirement(unitType2, 1);
+			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
+		}
+
+		[Test()]
+		public void TestAddingUnitTypeDefaultsToNoMoreThanZero()
+		{
+			Army army = new Army(mockRace, "Test", 1000);
+			AddUnitOfTypeToArmy(unitType2, army);
+			RequiresNoMoreThanNOfUnitTypeRequirement req = new RequiresNoMoreThanNOfUnitTypeRequirement();
+			req.AddUnitTypeRequirement(unitType2);
+			Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
+		}
+
 		private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
 		{
 			army.AddUnit(CreateUnitOfType(unitType, army));