diff API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs @ 68:a82f164e26e3

Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Add test for invalid default stats ID
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Jul 2010 19:11:08 +0000
parents d3191c44f163
children 90a9f13b9627
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sun Jul 04 15:05:00 2010 +0000
+++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sun Jul 04 19:11:08 2010 +0000
@@ -6,6 +6,8 @@
 using System.IO;
 using IBBoard.WarFoundry.API.Objects;
 using NUnit.Framework.SyntaxHelpers;
+using IBBoard.IO;
+using System.Xml.Schema;
 
 namespace IBBoard.WarFoundry.API.Factories.Xml
 {
@@ -36,6 +38,29 @@
 			Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats"));
 			Assert.That(system.SystemStats, Has.Length(2));
 		}
+		
+		[Test()]
+		public void TestIncorrectDefaultStatsIDErrors()
+		{
+			TestFileValidationFailure("testdata/xml-system-factory/invalid-default-stats.systemx");
+		}
+		
+		private void TestFileValidationFailure(string filePath)
+		{
+			FileInfo systemFile = new FileInfo(filePath);
+			
+			try
+			{
+				SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), systemFile);
+				Assert.Fail("Excepted exception not thrown");
+			}
+			catch (InvalidFileException ex)
+			{
+				Console.WriteLine(ex.Message);
+				Exception innerException = ex.InnerException;
+				Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException)));
+			}
+		}
 	}
 }