changeset 61:27625216d8d6

Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Add test for ability loading and validation when the ability exists * Move old test data for non-existant ability into sub-folder
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 Jun 2010 19:09:07 +0000
parents f2348c00e633
children ef8950a5f4cb
files API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/race-with-non-existant-ability.racex testdata/xml-race-factory/existing-ability.racex testdata/xml-race-factory/non-existant-ability.racex
diffstat 5 files changed, 69 insertions(+), 35 deletions(-) [+]
line diff
     1.1 --- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sat Jun 19 15:50:35 2010 +0000
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sat Jun 19 19:09:07 2010 +0000
     1.3 @@ -29,7 +29,7 @@
     1.4  		public void TestCompleteLoadingOnRaceWithMissingAbilityIdErrors()
     1.5  		{
     1.6  			SetDefaultGameSystem();
     1.7 -			FileInfo raceFile = new FileInfo("testdata/race-with-non-existant-ability.racex");
     1.8 +			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/non-existant-ability.racex");
     1.9  			
    1.10  			try
    1.11  			{
    1.12 @@ -43,6 +43,20 @@
    1.13  				Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException)));
    1.14  			}
    1.15  		}
    1.16 +
    1.17 +		[Test()]
    1.18 +		public void TestCompleteLoadingOnRaceWithAbilityLoadsData()
    1.19 +		{
    1.20 +			SetDefaultGameSystem();
    1.21 +			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-ability.racex");
    1.22 +			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
    1.23 +			UnitType unitType = race.GetUnitType("Empire1");
    1.24 +			Ability ability = race.GetAbility("leaderOfMen");
    1.25 +			Assert.That(ability.Name, Is.EqualTo("Leader of Men"));
    1.26 +			Assert.That(ability.Description, Is.EqualTo("All men will follow the character and can use his leadership"));
    1.27 +			Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability));
    1.28 +			
    1.29 +		}
    1.30  		
    1.31  		[Test()]
    1.32  		public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDError()
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Jun 19 15:50:35 2010 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sat Jun 19 19:09:07 2010 +0000
     2.3 @@ -76,9 +76,6 @@
     2.4      <None Include="testdata\race-with-non-existant-game-system.race">
     2.5        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     2.6      </None>
     2.7 -    <None Include="testdata\race-with-non-existant-ability.racex">
     2.8 -      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     2.9 -    </None>
    2.10      <None Include="testdata\extended-data.racex">
    2.11        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.12      </None>
    2.13 @@ -164,6 +161,12 @@
    2.14      <None Include="testdata\xml-race-factory\duplicate-extra-data-key.racex">
    2.15        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.16      </None>
    2.17 +    <None Include="testdata\xml-race-factory\non-existant-ability.racex">
    2.18 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.19 +    </None>
    2.20 +    <None Include="testdata\xml-race-factory\existing-ability.racex">
    2.21 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.22 +    </None>
    2.23    </ItemGroup>
    2.24    <ItemGroup>
    2.25      <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
    2.26 @@ -195,5 +198,6 @@
    2.27    </ProjectExtensions>
    2.28    <ItemGroup>
    2.29      <Folder Include="testdata\xml-race-factory\" />
    2.30 +    <Folder Include="testdata\" />
    2.31    </ItemGroup>
    2.32  </Project>
    2.33 \ No newline at end of file
     3.1 --- a/testdata/race-with-non-existant-ability.racex	Sat Jun 19 15:50:35 2010 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,31 +0,0 @@
     3.4 -<?xml version="1.0" encoding="UTF-8"?>
     3.5 -<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
     3.6 -	<units>
     3.7 -		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     3.8 -			<stats>
     3.9 -				<stat name="M">4</stat>
    3.10 -				<stat name="WS">6</stat>
    3.11 -				<stat name="BS">6</stat>
    3.12 -				<stat name="S">4</stat>
    3.13 -				<stat name="T">4</stat>
    3.14 -				<stat name="W">3</stat>
    3.15 -				<stat name="I">6</stat>
    3.16 -				<stat name="A">4</stat>
    3.17 -				<stat name="Ld">9</stat>
    3.18 -			</stats>
    3.19 -			<unitAbilities>
    3.20 -				<unitAbility abilityID="leaderOfMen"/>
    3.21 -			</unitAbilities>
    3.22 -		</unit>
    3.23 -	</units>
    3.24 -	<equipment>
    3.25 -		<equipmentItem id="equip1" name="sword" cost="1"/>
    3.26 -		<equipmentItem id="equip2" name="shield" cost="1"/>
    3.27 -		<equipmentItem id="equip3" name="broadsword" cost="2" />
    3.28 -		<equipmentItem id="equip4" name="Standard Guns" cost="3" />
    3.29 -		<equipmentItem id="equip5" name="Special Guns" cost="5" />
    3.30 -		<equipmentItem id="equip6" name="Long Gun" cost="4" />
    3.31 -		<equipmentItem id="equip7" name="Big Gun" cost="8" />
    3.32 -		<equipmentItem id="equip8" name="Quick Gun" cost="6" />
    3.33 -	</equipment>
    3.34 -</race>
    3.35 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/testdata/xml-race-factory/existing-ability.racex	Sat Jun 19 19:09:07 2010 +0000
     4.3 @@ -0,0 +1,26 @@
     4.4 +<?xml version="1.0" encoding="UTF-8"?>
     4.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
     4.6 +	<units>
     4.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     4.8 +			<stats>
     4.9 +				<stat name="M">4</stat>
    4.10 +				<stat name="WS">6</stat>
    4.11 +				<stat name="BS">6</stat>
    4.12 +				<stat name="S">4</stat>
    4.13 +				<stat name="T">4</stat>
    4.14 +				<stat name="W">3</stat>
    4.15 +				<stat name="I">6</stat>
    4.16 +				<stat name="A">4</stat>
    4.17 +				<stat name="Ld">9</stat>
    4.18 +			</stats>
    4.19 +			<unitAbilities>
    4.20 +				<unitAbility abilityID="leaderOfMen"/>
    4.21 +			</unitAbilities>
    4.22 +		</unit>
    4.23 +	</units>
    4.24 +	<abilities>
    4.25 +		<ability id="leaderOfMen" name="Leader of Men">
    4.26 +			<description>All men will follow the character and can use his leadership</description>
    4.27 +		</ability>
    4.28 +	</abilities>
    4.29 +</race>
    4.30 \ No newline at end of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/testdata/xml-race-factory/non-existant-ability.racex	Sat Jun 19 19:09:07 2010 +0000
     5.3 @@ -0,0 +1,21 @@
     5.4 +<?xml version="1.0" encoding="UTF-8"?>
     5.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
     5.6 +	<units>
     5.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     5.8 +			<stats>
     5.9 +				<stat name="M">4</stat>
    5.10 +				<stat name="WS">6</stat>
    5.11 +				<stat name="BS">6</stat>
    5.12 +				<stat name="S">4</stat>
    5.13 +				<stat name="T">4</stat>
    5.14 +				<stat name="W">3</stat>
    5.15 +				<stat name="I">6</stat>
    5.16 +				<stat name="A">4</stat>
    5.17 +				<stat name="Ld">9</stat>
    5.18 +			</stats>
    5.19 +			<unitAbilities>
    5.20 +				<unitAbility abilityID="leaderOfMen"/>
    5.21 +			</unitAbilities>
    5.22 +		</unit>
    5.23 +	</units>
    5.24 +</race>
    5.25 \ No newline at end of file