Mercurial > repos > IBBoard.WarFoundry.API.Tests
diff API/Objects/Requirement/AbstractRaceUnitRequirementTest.cs @ 217:9bf34e88da89
Re #379: Fix validation of requirements to check for unit
* Add equality tests to try to resolve UnitType tests for limits as requirements
* Ensure consistency with extra layer in hierarchy
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 05 Mar 2012 20:34:45 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Requirement/AbstractRaceUnitRequirementTest.cs Mon Mar 05 20:34:45 2012 +0000 @@ -0,0 +1,49 @@ +// This file (AbstractUnitTypeUnitRequirementTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2012 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 IBBoard.WarFoundry.API.Factories.Mock; + +namespace IBBoard.WarFoundry.API.Objects.Requirement +{ + public abstract class AbstractRaceUnitRequirementTest<OBJECT_TYPE, TEST_CLASS> : AbstractUnitRequirementTest<OBJECT_TYPE, TEST_CLASS> where OBJECT_TYPE : Race where TEST_CLASS : AbstractUnitRequirement<OBJECT_TYPE> + { + protected MockRace mockRace; + protected UnitType unitType1; + protected UnitType unitType2; + protected UnitType unitType3; + + [TestFixtureSetUp()] + public void SetupRace() + { + mockRace = new MockRace(); + unitType1 = new MockUnitType("type1", "Unit Type 1"); + mockRace.AddUnitType(unitType1); + unitType2 = new MockUnitType("type2", "Unit Type 2"); + mockRace.AddUnitType(unitType2); + unitType3 = new MockUnitType("type3", "Unit Type 3"); + mockRace.AddUnitType(unitType3); + } + + public override TEST_CLASS GetObject() + { + return CreateRequirement(mockRace); + } + + public override TEST_CLASS GetSameObject() + { + return CreateRequirement(mockRace); + } + + public override TEST_CLASS GetDifferentObject() + { + Race race = new Race("otherrace", "Other Race", MockGameSystem.GetMockSystem(), MockSystemFactory.GetMockFactory()); + return CreateRequirement(race); + } + + protected abstract TEST_CLASS CreateRequirement(Race requirementOn); + } +} +