changeset 66:f671ead260b1

Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Move some test data files to sub-folder * Test duplicate ID validation failures for equipment slots and equipment IDs * Test valid equipment references
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Jul 2010 14:28:13 +0000
parents fa536aee66d7
children d3191c44f163
files API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/invalid-contained-unit-reference.racex testdata/single-unit-with-invalid-equipment-reference.racex testdata/valid-contained-unit-reference.racex testdata/xml-race-factory/duplicate-equipment-id.racex testdata/xml-race-factory/invalid-contained-unit-reference.racex testdata/xml-race-factory/single-unit-with-duplicate-equipment-slot.racex testdata/xml-race-factory/single-unit-with-invalid-equipment-reference.racex testdata/xml-race-factory/single-unit-with-valid-equipment-reference.racex testdata/xml-race-factory/valid-contained-unit-reference.racex
diffstat 11 files changed, 204 insertions(+), 91 deletions(-) [+]
line diff
     1.1 --- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sun Jul 04 13:53:45 2010 +0000
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sun Jul 04 14:28:13 2010 +0000
     1.3 @@ -79,6 +79,12 @@
     1.4  		}
     1.5  
     1.6  		[Test()]
     1.7 +		public void TestCompleteLoadingOnRaceWithDuplicateEquipmentSlotErrors()
     1.8 +		{
     1.9 +			TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-duplicate-equipment-slot.racex");
    1.10 +		}
    1.11 +
    1.12 +		[Test()]
    1.13  		public void TestCompleteLoadingOnRaceWithCorrectEquipmentSlotLoads()
    1.14  		{
    1.15  			SetDefaultGameSystem();
    1.16 @@ -98,20 +104,36 @@
    1.17  		[Test()]
    1.18  		public void TestCompleteLoadingOnRaceWithIncorrectEquipmentIDError()
    1.19  		{
    1.20 -			TestFileValidationFailure("testdata/single-unit-with-invalid-equipment-reference.racex");
    1.21 +			TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-invalid-equipment-reference.racex");
    1.22 +		}
    1.23 +
    1.24 +		[Test()]
    1.25 +		public void TestCompleteLoadingOnRaceWithDuplicateEquipmentIDError()
    1.26 +		{
    1.27 +			TestFileValidationFailure("testdata/xml-race-factory/duplicate-equipment-id.racex");
    1.28 +		}
    1.29 +
    1.30 +		[Test()]
    1.31 +		public void TestCompleteLoadingOnRaceWithCorrectEquipmentIDLoads()
    1.32 +		{
    1.33 +			SetDefaultGameSystem();
    1.34 +			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/single-unit-with-valid-equipment-reference.racex");
    1.35 +			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
    1.36 +			UnitType unitType = race.GetUnitType("Empire1");
    1.37 +			Assert.That(unitType.GetEquipmentItem("Empire1equip1"), Is.Not.Null);
    1.38  		}
    1.39  
    1.40  		[Test()]
    1.41  		public void TestCompleteLoadingOnRaceWithIncorrectContainedUnitIDError()
    1.42  		{
    1.43 -			TestFileValidationFailure("testdata/invalid-contained-unit-reference.racex");
    1.44 +			TestFileValidationFailure("testdata/xml-race-factory/invalid-contained-unit-reference.racex");
    1.45  		}
    1.46  
    1.47  		[Test()]
    1.48  		public void TestCompleteLoadingOnRaceWithCorrectContainedUnitIDLoadsData()
    1.49  		{
    1.50  			SetDefaultGameSystem();
    1.51 -			FileInfo raceFile = new FileInfo("testdata/valid-contained-unit-reference.racex");
    1.52 +			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/valid-contained-unit-reference.racex");
    1.53  			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
    1.54  			UnitType unitType = race.GetUnitType("Empire1");
    1.55  			Assert.That(unitType.ContainedUnitTypes, Has.Length(1));
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sun Jul 04 13:53:45 2010 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Jul 04 14:28:13 2010 +0000
     2.3 @@ -103,9 +103,6 @@
     2.4      <None Include="testdata\single-unit-multi-type-referencing-race-with-override.racex">
     2.5        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     2.6      </None>
     2.7 -    <None Include="testdata\single-unit-with-invalid-equipment-reference.racex">
     2.8 -      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     2.9 -    </None>
    2.10      <None Include="testdata\single-unit-no-category.racex">
    2.11        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.12      </None>
    2.13 @@ -143,12 +140,6 @@
    2.14      <None Include="WarFoundryTests.nunit">
    2.15        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.16      </None>
    2.17 -    <None Include="testdata\invalid-contained-unit-reference.racex">
    2.18 -      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.19 -    </None>
    2.20 -    <None Include="testdata\valid-contained-unit-reference.racex">
    2.21 -      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.22 -    </None>
    2.23      <None Include="testdata\xml-race-factory\different-extra-data-key.racex">
    2.24        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.25      </None>
    2.26 @@ -182,6 +173,24 @@
    2.27      <None Include="testdata\xml-race-factory\single-unit-with-no-equipment-slot-limit.racex">
    2.28        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.29      </None>
    2.30 +    <None Include="testdata\xml-race-factory\single-unit-with-invalid-equipment-reference.racex">
    2.31 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.32 +    </None>
    2.33 +    <None Include="testdata\xml-race-factory\single-unit-with-valid-equipment-reference.racex">
    2.34 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.35 +    </None>
    2.36 +    <None Include="testdata\xml-race-factory\valid-contained-unit-reference.racex">
    2.37 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.38 +    </None>
    2.39 +    <None Include="testdata\xml-race-factory\invalid-contained-unit-reference.racex">
    2.40 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.41 +    </None>
    2.42 +    <None Include="testdata\xml-race-factory\single-unit-with-duplicate-equipment-slot.racex">
    2.43 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.44 +    </None>
    2.45 +    <None Include="testdata\xml-race-factory\duplicate-equipment-id.racex">
    2.46 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.47 +    </None>
    2.48    </ItemGroup>
    2.49    <ItemGroup>
    2.50      <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
     3.1 --- a/testdata/invalid-contained-unit-reference.racex	Sun Jul 04 13:53:45 2010 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,21 +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 -			<contains>
    3.20 -				<containedUnit containedID="Empire2" />
    3.21 -			</contains>
    3.22 -		</unit>
    3.23 -	</units>
    3.24 -</race>
    3.25 \ No newline at end of file
     4.1 --- a/testdata/single-unit-with-invalid-equipment-reference.racex	Sun Jul 04 13:53:45 2010 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,24 +0,0 @@
     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="nonexistant">
     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 -			<unitEquipment>
    4.20 -				<unitEquipmentItem id="equip2"/>
    4.21 -			</unitEquipment>
    4.22 -		</unit>
    4.23 -	</units>
    4.24 -	<equipment>
    4.25 -		<equipmentItem id="equip1" name="sword" cost="1"/>
    4.26 -	</equipment>
    4.27 -</race>
    4.28 \ No newline at end of file
     5.1 --- a/testdata/valid-contained-unit-reference.racex	Sun Jul 04 13:53:45 2010 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,34 +0,0 @@
     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 -			<contains>
    5.20 -				<containedUnit containedID="Empire2" />
    5.21 -			</contains>
    5.22 -		</unit>
    5.23 -		<unit id="Empire2" typeName="Minion" cat="cat1" points="0">
    5.24 -			<stats>
    5.25 -				<stat name="M">4</stat>
    5.26 -				<stat name="WS">2</stat>
    5.27 -				<stat name="BS">2</stat>
    5.28 -				<stat name="S">2</stat>
    5.29 -				<stat name="T">2</stat>
    5.30 -				<stat name="W">1</stat>
    5.31 -				<stat name="I">2</stat>
    5.32 -				<stat name="A">1</stat>
    5.33 -				<stat name="Ld">5</stat>
    5.34 -			</stats>
    5.35 -		</unit>
    5.36 -	</units>
    5.37 -</race>
    5.38 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/testdata/xml-race-factory/duplicate-equipment-id.racex	Sun Jul 04 14:28:13 2010 +0000
     6.3 @@ -0,0 +1,22 @@
     6.4 +<?xml version="1.0" encoding="UTF-8"?>
     6.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant">
     6.6 +	<units>
     6.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     6.8 +			<stats>
     6.9 +				<stat name="M">4</stat>
    6.10 +				<stat name="WS">6</stat>
    6.11 +				<stat name="BS">6</stat>
    6.12 +				<stat name="S">4</stat>
    6.13 +				<stat name="T">4</stat>
    6.14 +				<stat name="W">3</stat>
    6.15 +				<stat name="I">6</stat>
    6.16 +				<stat name="A">4</stat>
    6.17 +				<stat name="Ld">9</stat>
    6.18 +			</stats>
    6.19 +		</unit>
    6.20 +	</units>
    6.21 +	<equipment>
    6.22 +		<equipmentItem id="equip1" name="sword" cost="1"/>
    6.23 +		<equipmentItem id="equip1" name="other item" cost="1"/>
    6.24 +	</equipment>
    6.25 +</race>
    6.26 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/testdata/xml-race-factory/invalid-contained-unit-reference.racex	Sun Jul 04 14:28:13 2010 +0000
     7.3 @@ -0,0 +1,21 @@
     7.4 +<?xml version="1.0" encoding="UTF-8"?>
     7.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
     7.6 +	<units>
     7.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     7.8 +			<stats>
     7.9 +				<stat name="M">4</stat>
    7.10 +				<stat name="WS">6</stat>
    7.11 +				<stat name="BS">6</stat>
    7.12 +				<stat name="S">4</stat>
    7.13 +				<stat name="T">4</stat>
    7.14 +				<stat name="W">3</stat>
    7.15 +				<stat name="I">6</stat>
    7.16 +				<stat name="A">4</stat>
    7.17 +				<stat name="Ld">9</stat>
    7.18 +			</stats>
    7.19 +			<contains>
    7.20 +				<containedUnit containedID="Empire2" />
    7.21 +			</contains>
    7.22 +		</unit>
    7.23 +	</units>
    7.24 +</race>
    7.25 \ No newline at end of file
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/testdata/xml-race-factory/single-unit-with-duplicate-equipment-slot.racex	Sun Jul 04 14:28:13 2010 +0000
     8.3 @@ -0,0 +1,36 @@
     8.4 +<?xml version="1.0" encoding="UTF-8"?>
     8.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant">
     8.6 +	<units>
     8.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     8.8 +			<stats>
     8.9 +				<stat name="M">4</stat>
    8.10 +				<stat name="WS">6</stat>
    8.11 +				<stat name="BS">6</stat>
    8.12 +				<stat name="S">4</stat>
    8.13 +				<stat name="T">4</stat>
    8.14 +				<stat name="W">3</stat>
    8.15 +				<stat name="I">6</stat>
    8.16 +				<stat name="A">4</stat>
    8.17 +				<stat name="Ld">9</stat>
    8.18 +			</stats>
    8.19 +			<equipmentSlots>
    8.20 +				<equipmentSlot name="slot1">
    8.21 +					<maxLimit>
    8.22 +						<core:absoluteLimit limit="1" />
    8.23 +					</maxLimit>
    8.24 +				</equipmentSlot>
    8.25 +				<equipmentSlot name="slot1">
    8.26 +					<maxLimit>
    8.27 +						<core:absoluteLimit limit="1" />
    8.28 +					</maxLimit>
    8.29 +				</equipmentSlot>
    8.30 +			</equipmentSlots>
    8.31 +			<unitEquipment>
    8.32 +				<unitEquipmentItem id="equip1" equipmentSlot="slot1"/>
    8.33 +			</unitEquipment>
    8.34 +		</unit>
    8.35 +	</units>
    8.36 +	<equipment>
    8.37 +		<equipmentItem id="equip1" name="sword" cost="1"/>
    8.38 +	</equipment>
    8.39 +</race>
    8.40 \ No newline at end of file
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/testdata/xml-race-factory/single-unit-with-invalid-equipment-reference.racex	Sun Jul 04 14:28:13 2010 +0000
     9.3 @@ -0,0 +1,24 @@
     9.4 +<?xml version="1.0" encoding="UTF-8"?>
     9.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant">
     9.6 +	<units>
     9.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     9.8 +			<stats>
     9.9 +				<stat name="M">4</stat>
    9.10 +				<stat name="WS">6</stat>
    9.11 +				<stat name="BS">6</stat>
    9.12 +				<stat name="S">4</stat>
    9.13 +				<stat name="T">4</stat>
    9.14 +				<stat name="W">3</stat>
    9.15 +				<stat name="I">6</stat>
    9.16 +				<stat name="A">4</stat>
    9.17 +				<stat name="Ld">9</stat>
    9.18 +			</stats>
    9.19 +			<unitEquipment>
    9.20 +				<unitEquipmentItem id="equip2"/>
    9.21 +			</unitEquipment>
    9.22 +		</unit>
    9.23 +	</units>
    9.24 +	<equipment>
    9.25 +		<equipmentItem id="equip1" name="sword" cost="1"/>
    9.26 +	</equipment>
    9.27 +</race>
    9.28 \ No newline at end of file
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/testdata/xml-race-factory/single-unit-with-valid-equipment-reference.racex	Sun Jul 04 14:28:13 2010 +0000
    10.3 @@ -0,0 +1,24 @@
    10.4 +<?xml version="1.0" encoding="UTF-8"?>
    10.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant">
    10.6 +	<units>
    10.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
    10.8 +			<stats>
    10.9 +				<stat name="M">4</stat>
   10.10 +				<stat name="WS">6</stat>
   10.11 +				<stat name="BS">6</stat>
   10.12 +				<stat name="S">4</stat>
   10.13 +				<stat name="T">4</stat>
   10.14 +				<stat name="W">3</stat>
   10.15 +				<stat name="I">6</stat>
   10.16 +				<stat name="A">4</stat>
   10.17 +				<stat name="Ld">9</stat>
   10.18 +			</stats>
   10.19 +			<unitEquipment>
   10.20 +				<unitEquipmentItem id="equip1"/>
   10.21 +			</unitEquipment>
   10.22 +		</unit>
   10.23 +	</units>
   10.24 +	<equipment>
   10.25 +		<equipmentItem id="equip1" name="sword" cost="1"/>
   10.26 +	</equipment>
   10.27 +</race>
   10.28 \ No newline at end of file
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/testdata/xml-race-factory/valid-contained-unit-reference.racex	Sun Jul 04 14:28:13 2010 +0000
    11.3 @@ -0,0 +1,34 @@
    11.4 +<?xml version="1.0" encoding="UTF-8"?>
    11.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
    11.6 +	<units>
    11.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
    11.8 +			<stats>
    11.9 +				<stat name="M">4</stat>
   11.10 +				<stat name="WS">6</stat>
   11.11 +				<stat name="BS">6</stat>
   11.12 +				<stat name="S">4</stat>
   11.13 +				<stat name="T">4</stat>
   11.14 +				<stat name="W">3</stat>
   11.15 +				<stat name="I">6</stat>
   11.16 +				<stat name="A">4</stat>
   11.17 +				<stat name="Ld">9</stat>
   11.18 +			</stats>
   11.19 +			<contains>
   11.20 +				<containedUnit containedID="Empire2" />
   11.21 +			</contains>
   11.22 +		</unit>
   11.23 +		<unit id="Empire2" typeName="Minion" cat="cat1" points="0">
   11.24 +			<stats>
   11.25 +				<stat name="M">4</stat>
   11.26 +				<stat name="WS">2</stat>
   11.27 +				<stat name="BS">2</stat>
   11.28 +				<stat name="S">2</stat>
   11.29 +				<stat name="T">2</stat>
   11.30 +				<stat name="W">1</stat>
   11.31 +				<stat name="I">2</stat>
   11.32 +				<stat name="A">1</stat>
   11.33 +				<stat name="Ld">5</stat>
   11.34 +			</stats>
   11.35 +		</unit>
   11.36 +	</units>
   11.37 +</race>
   11.38 \ No newline at end of file