comparison API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 36:82cd08385bfe

Fixes #228: Crash on invalid ability ID * Replace zipped Race and System files with unpackaged XML * Add helper class to create WarFoundry objects from XML files for tests * Use new helper classes to make test pass
author IBBoard <dev@ibboard.co.uk>
date Thu, 24 Dec 2009 20:14:28 +0000
parents 4302e6b2c5c1
children 00abd1c2f7d6
comparison
equal deleted inserted replaced
35:4302e6b2c5c1 36:82cd08385bfe
22 [ExpectedException(typeof(InvalidFileException), ExpectedMessage="Ability for Empire General with ID leaderOfMen did not exist in race definition")] 22 [ExpectedException(typeof(InvalidFileException), ExpectedMessage="Ability for Empire General with ID leaderOfMen did not exist in race definition")]
23 public void TestCompleteLoadingOnRaceWithMissingAbilityIdErrors () 23 public void TestCompleteLoadingOnRaceWithMissingAbilityIdErrors ()
24 { 24 {
25 try 25 try
26 { 26 {
27 WarFoundryLoader.SetDefault(new FixedGameSystemWarFoundryLoader(new MockGameSystem())); 27 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/race-with-non-existant-ability.systemx"));
28 WarFoundryLoader.GetDefault().LoadFiles(); 28 FixedGameSystemWarFoundryLoader fixedLoader = new FixedGameSystemWarFoundryLoader(system);
29 ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/race-with-non-existant-ability.race")); 29 WarFoundryLoader.SetDefault(fixedLoader);
30 Assert.AreEqual(1, objs.Count); 30 FileInfo raceFile = new FileInfo ("testdata/race-with-non-existant-ability.racex");
31 IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); 31 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
32 enumerator.Reset();
33 enumerator.MoveNext();
34 Race race = (Race)enumerator.Current;
35 Category[] cats = race.Categories; 32 Category[] cats = race.Categories;
36 } 33 }
37 finally 34 finally
38 { 35 {
39 WarFoundryLoader.SetDefault(null); 36 WarFoundryLoader.SetDefault(null);