# HG changeset patch # User IBBoard # Date 1303744194 0 # Node ID d28c3c1ec1ecf66e372cd947af3b560c22dac57a # Parent 8c3bba80a25e95454098ce3683462fa7898efac5 Re #27: Unit requirements * Make sure that units return their limits as requirements on the army diff -r 8c3bba80a25e -r d28c3c1ec1ec API/Objects/UnitTypeTest.cs --- a/API/Objects/UnitTypeTest.cs Mon Apr 25 10:31:49 2011 +0000 +++ b/API/Objects/UnitTypeTest.cs Mon Apr 25 15:09:54 2011 +0000 @@ -55,6 +55,21 @@ unitType.AddRequirement(req); Assert.That(unitType.GetRequirements(), Has.Length(1)); } + + [Test] + public void TestGetRequirementsGetsUnitCountRequirements() + { + UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace()); + unitType.MinNumber = 1; + unitType.MaxNumber = 2; + Assert.That(unitType.GetRequirements(), Has.Length(2)); + RequiresNoMoreThanNOfUnitTypeRequirement maxLimit = new RequiresNoMoreThanNOfUnitTypeRequirement(); + maxLimit.AddUnitTypeRequirement(unitType, 2); + Assert.That(unitType.GetRequirements(), Has.Member(maxLimit)); + RequiresAtLeastNUnitsRequirement minLimit = new RequiresAtLeastNUnitsRequirement(); + minLimit.AddUnitTypeRequirement(unitType, 1); + Assert.That(unitType.GetRequirements(), Has.Member(minLimit)); + } } }