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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs	Mon Jun 13 20:04:40 2011 +0000
     1.3 @@ -0,0 +1,47 @@
     1.4 +// This file (UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
     1.5 +// 
     1.6 +// 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.
     1.7 +using System;
     1.8 +using NUnit.Framework;
     1.9 +using IBBoard.WarFoundry.API.Objects.Mock;
    1.10 +using NUnit.Framework.SyntaxHelpers;
    1.11 +using IBBoard.WarFoundry.API.Objects;
    1.12 +using IBBoard.WarFoundry.API.Objects.Requirement;
    1.13 +
    1.14 +namespace IBBoard.WarFoundry.API.Factories.Requirement
    1.15 +{
    1.16 +	[TestFixture()]
    1.17 +	public class UnitRequiresAtLeastNUnitsRequirementFactoryTest
    1.18 +	{
    1.19 +		private static Race race;
    1.20 +		private static string typeID = "unit1";
    1.21 +		private UnitType unitType1;
    1.22 +
    1.23 +		[TestFixtureSetUp()]
    1.24 +		public void Setup()
    1.25 +		{
    1.26 +			race = new MockRace();
    1.27 +			unitType1 = new UnitType(typeID, "Unit 1", race);
    1.28 +			race.AddUnitType(unitType1);
    1.29 +		}
    1.30 +
    1.31 +		[Test()]
    1.32 +		public void TestCreatesRequirement()
    1.33 +		{
    1.34 +			UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory();
    1.35 +			Assert.That(factory.CreateRequirement(new MockUnitType(), typeID), Is.Not.Null);
    1.36 +		}
    1.37 +
    1.38 +		[Test()]
    1.39 +		public void TestCreatesCorrectRequirement()
    1.40 +		{
    1.41 +			UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory();
    1.42 +			UnitType unitType = new UnitType("unit2", "Unit 2", race);
    1.43 +			UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType);
    1.44 +			expectedReq.AddUnitTypeRequirement(unitType1);
    1.45 +			UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID);
    1.46 +			Assert.That(req, Is.EqualTo(expectedReq));
    1.47 +		}
    1.48 +	}
    1.49 +}
    1.50 +
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Mon Jun 13 18:59:43 2011 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Mon Jun 13 20:04:40 2011 +0000
     2.3 @@ -103,6 +103,7 @@
     2.4      <Compile Include="API\Objects\Requirement\Mock\PassingRequirement.cs" />
     2.5      <Compile Include="API\Objects\Requirement\Mock\NotApplicableRequirement.cs" />
     2.6      <Compile Include="API\Objects\Requirement\UnitCountRequirementDataTest.cs" />
     2.7 +    <Compile Include="API\Factories\Requirement\UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs" />
     2.8    </ItemGroup>
     2.9    <ItemGroup>
    2.10      <None Include="app.config" />
    2.11 @@ -362,5 +363,6 @@
    2.12    <ItemGroup>
    2.13      <Folder Include="API\Savers\Xml\" />
    2.14      <Folder Include="API\Objects\Requirement\Mock\" />
    2.15 +    <Folder Include="API\Factories\Requirement\" />
    2.16    </ItemGroup>
    2.17  </Project>
    2.18 \ No newline at end of file