changeset 129:95dac00e9330

Re #27: Unit requirements * Test getting all unit requirements for race
author IBBoard <dev@ibboard.co.uk>
date Sat, 09 Apr 2011 19:13:42 +0000
parents 7ca536ccd27a
children 7fa4d5215afe
files API/Objects/RaceTests.cs
diffstat 1 files changed, 45 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/RaceTests.cs	Sat Apr 09 15:59:55 2011 +0000
     1.2 +++ b/API/Objects/RaceTests.cs	Sat Apr 09 19:13:42 2011 +0000
     1.3 @@ -4,7 +4,9 @@
     1.4  using System;
     1.5  using NUnit.Framework;
     1.6  using IBBoard.WarFoundry.API.Objects.Mock;
     1.7 -using NUnit.Framework.SyntaxHelpers;
     1.8 +using NUnit.Framework.SyntaxHelpers;
     1.9 +using IBBoard.WarFoundry.API.Objects.Requirement;
    1.10 +using System.Collections.Generic;
    1.11  
    1.12  namespace IBBoard.WarFoundry.API.Objects
    1.13  {
    1.14 @@ -15,6 +17,48 @@
    1.15  		public void TestRaceWithNoUnitTypesHasNoRequirements()
    1.16  		{
    1.17  			Assert.That(new MockRace().GetRequirements(), Has.Count(0));
    1.18 +		}
    1.19 +
    1.20 +		[Test()]
    1.21 +		public void TestRaceWithOneUnitTypeHasNoRequirements()
    1.22 +		{
    1.23 +			MockRace race = new MockRace();
    1.24 +			race.AddUnitType(new MockUnitType());
    1.25 +			Assert.That(race.GetRequirements(), Has.Count(0));
    1.26 +		}
    1.27 +
    1.28 +		[Test()]
    1.29 +		public void TestRaceWithOneUnitTypeWithOneRequirementHasOneRequirement()
    1.30 +		{
    1.31 +			MockRace race = new MockRace();
    1.32 +			MockUnitType unitType = new MockUnitType();
    1.33 +			UnitRequiresAtLeastNUnitsRequirement unitRequirement = new UnitRequiresAtLeastNUnitsRequirement(unitType);
    1.34 +			unitType.AddRequirement(unitRequirement);
    1.35 +			race.AddUnitType(unitType);
    1.36 +			ICollection<IRequirement> raceRequirements = race.GetRequirements();
    1.37 +			Assert.That(raceRequirements, Has.Count(1));
    1.38 +			Assert.That(raceRequirements, Has.All.EqualTo(unitRequirement));
    1.39 +		}
    1.40 +
    1.41 +		[Test()]
    1.42 +		public void TestRaceWithTwoUnitTypesWithMultipleRequirementsHasMultipleRequirements()
    1.43 +		{
    1.44 +			MockRace race = new MockRace();
    1.45 +			MockUnitType unitType1 = new MockUnitType("type1", "Type 1");
    1.46 +			UnitRequiresAtLeastNUnitsRequirement unitRequirement1 = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
    1.47 +			unitType1.AddRequirement(unitRequirement1);
    1.48 +			UnitRequiresNoMoreThanNOfUnitTypeRequirement unitRequirement2 = new UnitRequiresNoMoreThanNOfUnitTypeRequirement(unitType1);
    1.49 +			unitType1.AddRequirement(unitRequirement2);
    1.50 +			race.AddUnitType(unitType1);
    1.51 +			MockUnitType unitType2 = new MockUnitType("type2", "Type 2");
    1.52 +			UnitRequiresAtLeastNUnitsRequirement unitRequirement3 = new UnitRequiresAtLeastNUnitsRequirement(unitType2);
    1.53 +			unitType2.AddRequirement(unitRequirement3);
    1.54 +			race.AddUnitType(unitType2);
    1.55 +			ICollection<IRequirement> raceRequirements = race.GetRequirements();
    1.56 +			Assert.That(raceRequirements, Has.Count(3));
    1.57 +			Assert.That(raceRequirements, Has.Member(unitRequirement1));
    1.58 +			Assert.That(raceRequirements, Has.Member(unitRequirement2));
    1.59 +			Assert.That(raceRequirements, Has.Member(unitRequirement3));
    1.60  		}
    1.61  	}
    1.62  }