view API/Objects/Requirements/UnitRequiresAtLeastNUnitsRequirementTest.cs @ 102:a3bc8174299f

Re #27: Define unit requirements * First test for first new style requirement * Update some of the Mock objects to add a few more required elements (mainly Category)
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Mar 2011 17:04:09 +0000
parents
children c6562eb62d04
line wrap: on
line source

// This file (UnitRequiresAtLeastNUnitsRequirement.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;

namespace IBBoard.WarFoundry.API.Objects.Requirements
{
	[TestFixture()]
	public class UnitRequiresAtLeastNUnitsRequirementTest
	{
		[Test()]
		public void TestWithNoUnits()
		{
			MockRace mockRace = MockRace.GetMockRace();
			UnitType unitType1 = new MockUnitType("type1", "Unit Type 1");
			mockRace.AddUnitType(unitType1);
			UnitType unitType2 = new MockUnitType("type2", "Unit Type 2");
			mockRace.AddUnitType(unitType2);
			Army army = new Army(mockRace, "Test", 1000);
			UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1, unitType2);
			Unit unit = new Unit(unitType1, army.GetCategory(unitType1.MainCategory));
			Assert.That(req.CanAddToArmy(unit, army), Is.False);
		}
	}
}