diff API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 62:ef8950a5f4cb

Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Test duplicate member type keys * Test valid case of member type key with reference * Move existing "non-existant member type" data to sub-folder and rename
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 Jun 2010 19:30:58 +0000
parents 27625216d8d6
children a9163f8dfba1
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sat Jun 19 19:09:07 2010 +0000
+++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sat Jun 19 19:30:58 2010 +0000
@@ -45,6 +45,25 @@
 		}
 
 		[Test()]
+		public void TestCompleteLoadingOnRaceWithDuplicateAbilityIdErrors()
+		{
+			SetDefaultGameSystem();
+			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/duplicate-ability.racex");
+			
+			try
+			{
+				SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
+				Assert.Fail("Excepted exception not thrown");
+			}
+			catch (InvalidFileException ex)
+			{
+				Console.WriteLine(ex.Message);
+				Exception innerException = ex.InnerException;
+				Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException)));
+			}
+		}
+
+		[Test()]
 		public void TestCompleteLoadingOnRaceWithAbilityLoadsData()
 		{
 			SetDefaultGameSystem();
@@ -54,15 +73,14 @@
 			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));
-			
+			Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability));			
 		}
 		
 		[Test()]
-		public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDError()
+		public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDErrors()
 		{
 			SetDefaultGameSystem();
-			FileInfo raceFile = new FileInfo("testdata/single-unit-non-existant-type-referencing-race.racex");
+			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/non-existant-member-type.racex");
 			
 			try
 			{
@@ -78,6 +96,35 @@
 		}
 
 		[Test()]
+		public void TestCompleteLoadingOnRaceWithDuplicateMemberTypeIDErrors()
+		{
+			SetDefaultGameSystem();
+			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/duplicate-member-type.racex");
+			
+			try
+			{
+				SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
+				Assert.Fail("Excepted exception not thrown");
+			}
+			catch (InvalidFileException ex)
+			{
+				Console.WriteLine(ex.Message);
+				Exception innerException = ex.InnerException;
+				Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException)));
+			}
+		}
+
+		[Test()]
+		public void TestCompleteLoadingOnRaceWithMemberTypeLoadsData()
+		{
+			SetDefaultGameSystem();
+			FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-member-type.racex");
+			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
+			UnitMemberType memberType = race.GetUnitMemberType("General");
+			Assert.That(memberType.Name, Is.EqualTo("General"));
+		}
+
+		[Test()]
 		public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors()
 		{
 			SetDefaultGameSystem();