Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 150:b86955aa252c
Re #351: Add extensible requirement handling method
* Start testing requirement factory
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 13 Jun 2011 20:04:40 +0000 |
parents | 71b9364f0276 |
children | 60de02ce78d8 |
files | API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj |
diffstat | 2 files changed, 49 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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)); + } + } +} +
--- 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 @@ <Compile Include="API\Objects\Requirement\Mock\PassingRequirement.cs" /> <Compile Include="API\Objects\Requirement\Mock\NotApplicableRequirement.cs" /> <Compile Include="API\Objects\Requirement\UnitCountRequirementDataTest.cs" /> + <Compile Include="API\Factories\Requirement\UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> @@ -362,5 +363,6 @@ <ItemGroup> <Folder Include="API\Savers\Xml\" /> <Folder Include="API\Objects\Requirement\Mock\" /> + <Folder Include="API\Factories\Requirement\" /> </ItemGroup> </Project> \ No newline at end of file