# HG changeset patch # User IBBoard # Date 1302346706 0 # Node ID c9fee4fdc9e885509498c975761f9b73327dd396 # Parent 14a007cf24460910e28304c781753877fdbc2895 Re #27: Unit requirements * Add matching test for unit type requiring at least N units diff -r 14a007cf2446 -r c9fee4fdc9e8 API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs --- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs Sat Apr 09 10:56:30 2011 +0000 +++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs Sat Apr 09 10:58:26 2011 +0000 @@ -185,6 +185,18 @@ Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed)); } + [Test] + public void TestAddingMinNumberUnitTypePassesRequirement() + { + Army army = new Army(mockRace, "Test", 1000); + AddUnitOfTypeToArmy(unitType1, army); + RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1); + req.AddUnitTypeRequirement(unitType2, 2); + Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed)); + AddUnitOfTypeToArmy(unitType2, army); + Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed)); + } + private static void AddUnitOfTypeToArmy(UnitType unitType, Army army) {