Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
diff API/Factories/Xml/WarFoundryXmlFactoryTests.cs @ 229:6ec46f3db2d4
Re #419: Remove assumptions of a file-based install
* Test loading from resources
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 11 Jul 2012 20:33:11 +0100 |
parents | 7c21ca1482cb |
children | e173c5512067 |
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlFactoryTests.cs Sat Jul 07 21:02:53 2012 +0100 +++ b/API/Factories/Xml/WarFoundryXmlFactoryTests.cs Wed Jul 11 20:33:11 2012 +0100 @@ -31,8 +31,7 @@ { raceCount++; } - else - if (obj is GameSystem) + else if (obj is GameSystem) { systemCount++; } @@ -67,8 +66,7 @@ { raceCount++; } - else - if (obj is GameSystem) + else if (obj is GameSystem) { systemCount++; } @@ -103,13 +101,12 @@ { raceCount++; } - else - if (obj is GameSystem) + else if (obj is GameSystem) { systemCount++; } } - + Assert.That(raceCount, Is.EqualTo(2)); Assert.That(systemCount, Is.EqualTo(2)); } @@ -118,5 +115,30 @@ loader.UnregisterFactory(factory); } } + + [Test()] + public void TestLoadingRaceFromResource() + { + WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); + GameSystem system = new GameSystem("sample", "Sample System", factory); + FixedGameSystemWarFoundryLoader fixedLoader = new FixedGameSystemWarFoundryLoader(system); + WarFoundryLoader.SetDefault(fixedLoader); + ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new LoadableResourceObject(typeof(WarFoundryLoader).Assembly, "IBBoard.WarFoundry.data.Empire.race")); + Assert.That(objs, Has.Count(1)); + IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); + enumerator.MoveNext(); + Assert.That(enumerator.Current, Is.TypeOf(typeof(Race))); + } + + [Test()] + public void TestLoadingSystemFromResource() + { + WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); + ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new LoadableResourceObject(typeof(WarFoundryLoader).Assembly, "IBBoard.WarFoundry.data.SampleSystem.system")); + Assert.That(objs, Has.Count(1)); + IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); + enumerator.MoveNext(); + Assert.That(enumerator.Current, Is.TypeOf(typeof(GameSystem))); + } } }