# HG changeset patch # User IBBoard # Date 1307995480 0 # Node ID b86955aa252c50116b34ac4285dc4868fa3d0487 # Parent 71b9364f027624d55b3ea81cbf8d7b04c6fab63f Re #351: Add extensible requirement handling method * Start testing requirement factory diff -r 71b9364f0276 -r b86955aa252c API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs Mon Jun 13 20:04:40 2011 +0000 @@ -0,0 +1,47 @@ +// This file (UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard +// +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. +using System; +using NUnit.Framework; +using IBBoard.WarFoundry.API.Objects.Mock; +using NUnit.Framework.SyntaxHelpers; +using IBBoard.WarFoundry.API.Objects; +using IBBoard.WarFoundry.API.Objects.Requirement; + +namespace IBBoard.WarFoundry.API.Factories.Requirement +{ + [TestFixture()] + public class UnitRequiresAtLeastNUnitsRequirementFactoryTest + { + private static Race race; + private static string typeID = "unit1"; + private UnitType unitType1; + + [TestFixtureSetUp()] + public void Setup() + { + race = new MockRace(); + unitType1 = new UnitType(typeID, "Unit 1", race); + race.AddUnitType(unitType1); + } + + [Test()] + public void TestCreatesRequirement() + { + UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); + Assert.That(factory.CreateRequirement(new MockUnitType(), typeID), Is.Not.Null); + } + + [Test()] + public void TestCreatesCorrectRequirement() + { + UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); + UnitType unitType = new UnitType("unit2", "Unit 2", race); + UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType); + expectedReq.AddUnitTypeRequirement(unitType1); + UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID); + Assert.That(req, Is.EqualTo(expectedReq)); + } + } +} + diff -r 71b9364f0276 -r b86955aa252c IBBoard.WarFoundry.API.Tests.csproj --- a/IBBoard.WarFoundry.API.Tests.csproj Mon Jun 13 18:59:43 2011 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Mon Jun 13 20:04:40 2011 +0000 @@ -103,6 +103,7 @@ + @@ -362,5 +363,6 @@ + \ No newline at end of file