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 wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sat Jun 19 15:50:35 2010 +0000
+++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sat Jun 19 19:09:07 2010 +0000
@@ -29,7 +29,7 @@
 		public void TestCompleteLoadingOnRaceWithMissingAbilityIdErrors()
 		{
 			SetDefaultGameSystem();
-			FileInfo raceFile = new FileInfo("testdata/race-with-non-existant-ability.racex");
+			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/non-existant-ability.racex");
 			
 			try
 			{
@@ -43,6 +43,20 @@
 				Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException)));
 			}
 		}
+
+		[Test()]
+		public void TestCompleteLoadingOnRaceWithAbilityLoadsData()
+		{
+			SetDefaultGameSystem();
+			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-ability.racex");
+			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
+			UnitType unitType = race.GetUnitType("Empire1");
+			Ability ability = race.GetAbility("leaderOfMen");
+			Assert.That(ability.Name, Is.EqualTo("Leader of Men"));
+			Assert.That(ability.Description, Is.EqualTo("All men will follow the character and can use his leadership"));
+			Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability));
+			
+		}
 		
 		[Test()]
 		public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDError()
--- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Jun 19 15:50:35 2010 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Sat Jun 19 19:09:07 2010 +0000
@@ -76,9 +76,6 @@
     <None Include="testdata\race-with-non-existant-game-system.race">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <None Include="testdata\race-with-non-existant-ability.racex">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
     <None Include="testdata\extended-data.racex">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
@@ -164,6 +161,12 @@
     <None Include="testdata\xml-race-factory\duplicate-extra-data-key.racex">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="testdata\xml-race-factory\non-existant-ability.racex">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="testdata\xml-race-factory\existing-ability.racex">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
@@ -195,5 +198,6 @@
   </ProjectExtensions>
   <ItemGroup>
     <Folder Include="testdata\xml-race-factory\" />
+    <Folder Include="testdata\" />
   </ItemGroup>
 </Project>
\ No newline at end of file
--- a/testdata/race-with-non-existant-ability.racex	Sat Jun 19 15:50:35 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
-	<units>
-		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
-			<stats>
-				<stat name="M">4</stat>
-				<stat name="WS">6</stat>
-				<stat name="BS">6</stat>
-				<stat name="S">4</stat>
-				<stat name="T">4</stat>
-				<stat name="W">3</stat>
-				<stat name="I">6</stat>
-				<stat name="A">4</stat>
-				<stat name="Ld">9</stat>
-			</stats>
-			<unitAbilities>
-				<unitAbility abilityID="leaderOfMen"/>
-			</unitAbilities>
-		</unit>
-	</units>
-	<equipment>
-		<equipmentItem id="equip1" name="sword" cost="1"/>
-		<equipmentItem id="equip2" name="shield" cost="1"/>
-		<equipmentItem id="equip3" name="broadsword" cost="2" />
-		<equipmentItem id="equip4" name="Standard Guns" cost="3" />
-		<equipmentItem id="equip5" name="Special Guns" cost="5" />
-		<equipmentItem id="equip6" name="Long Gun" cost="4" />
-		<equipmentItem id="equip7" name="Big Gun" cost="8" />
-		<equipmentItem id="equip8" name="Quick Gun" cost="6" />
-	</equipment>
-</race>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testdata/xml-race-factory/existing-ability.racex	Sat Jun 19 19:09:07 2010 +0000
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
+	<units>
+		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
+			<stats>
+				<stat name="M">4</stat>
+				<stat name="WS">6</stat>
+				<stat name="BS">6</stat>
+				<stat name="S">4</stat>
+				<stat name="T">4</stat>
+				<stat name="W">3</stat>
+				<stat name="I">6</stat>
+				<stat name="A">4</stat>
+				<stat name="Ld">9</stat>
+			</stats>
+			<unitAbilities>
+				<unitAbility abilityID="leaderOfMen"/>
+			</unitAbilities>
+		</unit>
+	</units>
+	<abilities>
+		<ability id="leaderOfMen" name="Leader of Men">
+			<description>All men will follow the character and can use his leadership</description>
+		</ability>
+	</abilities>
+</race>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testdata/xml-race-factory/non-existant-ability.racex	Sat Jun 19 19:09:07 2010 +0000
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default">
+	<units>
+		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
+			<stats>
+				<stat name="M">4</stat>
+				<stat name="WS">6</stat>
+				<stat name="BS">6</stat>
+				<stat name="S">4</stat>
+				<stat name="T">4</stat>
+				<stat name="W">3</stat>
+				<stat name="I">6</stat>
+				<stat name="A">4</stat>
+				<stat name="Ld">9</stat>
+			</stats>
+			<unitAbilities>
+				<unitAbility abilityID="leaderOfMen"/>
+			</unitAbilities>
+		</unit>
+	</units>
+</race>
\ No newline at end of file