view API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs @ 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
children 60de02ce78d8
line wrap: on
line source

// 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));
		}
	}
}