diff API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 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 04d7cd276b1d
children d3519f38a0f4
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)