changeset 47:b4b4bde843d7

Re #274: crash when missing unitMember id * Tests and test data for unit member crash. Schema should be able to validate using key/keyref, but can't get it working at the moment.
author IBBoard <dev@ibboard.co.uk>
date Tue, 18 May 2010 18:40:27 +0000
parents 73308371f9d8
children ea8d30377a72
files API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/single-unit-multi-type-referencing-race-with-override.racex testdata/single-unit-multi-type-referencing-race.racex testdata/single-unit-non-existant-type-referencing-race.racex testdata/single-unit-type-referencing-race.racex testdata/single-unit-with-invalid-equipment-reference.racex
diffstat 7 files changed, 51 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Mon May 17 20:04:13 2010 +0000
+++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Tue May 18 18:40:27 2010 +0000
@@ -2,14 +2,11 @@
 // 
 // 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 IBBoard.IO;
+using IBBoard.WarFoundry.API.Objects;
+using NUnit.Framework;
 using System.Collections.Generic;
 using System.IO;
-using System.Xml;
-using NUnit.Framework;
-using IBBoard.WarFoundry.API.Objects;
-using IBBoard.WarFoundry.API.Objects.Mock;
-using IBBoard.IO;
 
 namespace IBBoard.WarFoundry.API.Factories.Xml
 {
@@ -43,6 +40,16 @@
 			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
 			race.EnsureFullyLoaded();
 		}
+
+		[Test()]
+		[ExpectedException(typeof(InvalidFileException), ExpectedMessage = "TBD")]
+		public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors()
+		{
+			SetDefaultGameSystem();
+			FileInfo raceFile = new FileInfo("testdata/single-unit-with-invalid-equipment-reference.racex");
+			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
+			race.EnsureFullyLoaded();
+		}
 		
 		[Test()]
 		[ExpectedException(typeof(InvalidFileException), ExpectedMessage="Referenced game system, 'nonexistant-system', did not exist")]
@@ -147,9 +154,8 @@
 		}
 		
 		private static void SetDefaultGameSystem()
-		{			
-			FileInfo systemFile = new FileInfo("testdata/default.systemx");
-			SetDefaultGameSystem(systemFile);
+		{
+			SetDefaultGameSystem(new FileInfo("testdata/default.systemx"));
 		}
 		
 		public static void SetDefaultGameSystem(FileInfo systemFile)
--- a/IBBoard.WarFoundry.API.Tests.csproj	Mon May 17 20:04:13 2010 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Tue May 18 18:40:27 2010 +0000
@@ -109,6 +109,9 @@
     <None Include="testdata\single-unit-non-existant-type-referencing-race.racex">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="testdata\single-unit-with-invalid-equipment-reference.racex">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
--- a/testdata/single-unit-multi-type-referencing-race-with-override.racex	Mon May 17 20:04:13 2010 +0000
+++ b/testdata/single-unit-multi-type-referencing-race-with-override.racex	Tue May 18 18:40:27 2010 +0000
@@ -20,7 +20,7 @@
 		</unit>
 	</units>
 	<memberTypes>
-		<memberType id="General" name="General">
+		<memberType typeID="General" name="General">
 			<stats>
 				<stat name="M">4</stat>
 				<stat name="WS">6</stat>
@@ -33,7 +33,7 @@
 				<stat name="Ld">9</stat>
 			</stats>
 		</memberType>
-		<memberType id="Warhorse" name="Warhorse">
+		<memberType typeID="Warhorse" name="Warhorse">
 			<stats>
 				<stat name="M">8</stat>
 				<stat name="WS">3</stat>
--- a/testdata/single-unit-multi-type-referencing-race.racex	Mon May 17 20:04:13 2010 +0000
+++ b/testdata/single-unit-multi-type-referencing-race.racex	Tue May 18 18:40:27 2010 +0000
@@ -9,7 +9,7 @@
 		</unit>
 	</units>
 	<memberTypes>
-		<memberType id="General" name="General">
+		<memberType typeID="General" name="General">
 			<stats>
 				<stat name="M">4</stat>
 				<stat name="WS">6</stat>
@@ -22,7 +22,7 @@
 				<stat name="Ld">9</stat>
 			</stats>
 		</memberType>
-		<memberType id="Warhorse" name="Warhorse">
+		<memberType typeID="Warhorse" name="Warhorse">
 			<stats>
 				<stat name="M">8</stat>
 				<stat name="WS">3</stat>
--- a/testdata/single-unit-non-existant-type-referencing-race.racex	Mon May 17 20:04:13 2010 +0000
+++ b/testdata/single-unit-non-existant-type-referencing-race.racex	Tue May 18 18:40:27 2010 +0000
@@ -8,7 +8,7 @@
 		</unit>
 	</units>
 	<memberTypes>
-		<memberType id="General" name="General">
+		<memberType typeID="General" name="General">
 			<stats>
 				<stat name="M">4</stat>
 				<stat name="WS">6</stat>
--- a/testdata/single-unit-type-referencing-race.racex	Mon May 17 20:04:13 2010 +0000
+++ b/testdata/single-unit-type-referencing-race.racex	Tue May 18 18:40:27 2010 +0000
@@ -8,7 +8,7 @@
 		</unit>
 	</units>
 	<memberTypes>
-		<memberType id="General" name="General">
+		<memberType typeID="General" name="General">
 			<stats>
 				<stat name="M">4</stat>
 				<stat name="WS">6</stat>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testdata/single-unit-with-invalid-equipment-reference.racex	Tue May 18 18:40:27 2010 +0000
@@ -0,0 +1,27 @@
+<?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="nonexistant">
+	<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>
+			<equipmentSlots>
+				<equipmentSlot name="slot1"/>
+			</equipmentSlots>
+			<unitEquipment>
+				<unitEquipmentItem id="equip1" equipmentSlot="slot2"/>
+			</unitEquipment>
+		</unit>
+	</units>
+	<equipment>
+		<equipmentItem id="equip1" name="sword" cost="1"/>
+	</equipment>
+</race>
\ No newline at end of file