Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 90:5d19fee8e9dc
Re #253: Allow multiple data files in a single zip
* Differentiate in simple cache by concating strings
* Add extra tests for .race file and non-default names
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 27 Feb 2011 20:33:12 +0000 |
parents | 90dee8d781ee |
children | 98539b2fe8fa |
files | API/EventListeningWarFoundryLoader.cs API/Factories/Xml/WarFoundryXmlFactoryTests.cs |
diffstat | 2 files changed, 59 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/API/EventListeningWarFoundryLoader.cs Sun Feb 27 19:44:08 2011 +0000 +++ b/API/EventListeningWarFoundryLoader.cs Sun Feb 27 20:33:12 2011 +0000 @@ -39,7 +39,7 @@ protected override void DoStoreRace (Race race) { - races.Add(race.ID, race); + races.Add(race.GameSystem.ID + race.ID, race); }
--- a/API/Factories/Xml/WarFoundryXmlFactoryTests.cs Sun Feb 27 19:44:08 2011 +0000 +++ b/API/Factories/Xml/WarFoundryXmlFactoryTests.cs Sun Feb 27 20:33:12 2011 +0000 @@ -13,9 +13,9 @@ [Test()] public void TestFactoryHandlesMultipleFilesWithOldNamesInOneSystemZip() { - EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader (); + EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader(); WarFoundryLoader.SetDefault(loader); - WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory (); + WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); loader.RegisterFactory(factory); ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.system")); Assert.That(objs, Has.Count(2)); @@ -37,5 +37,61 @@ Assert.That(raceCount, Is.EqualTo(1)); Assert.That(systemCount, Is.EqualTo(1)); } + + [Test()] + public void TestFactoryHandlesMultipleFilesWithOldNamesInOneRaceZip() + { + EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader(); + WarFoundryLoader.SetDefault(loader); + WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); + loader.RegisterFactory(factory); + ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.race")); + Assert.That(objs, Has.Count(2)); + int raceCount = 0; + int systemCount = 0; + + foreach (IWarFoundryObject obj in objs) + { + if (obj is Race) + { + raceCount++; + } + else if (obj is GameSystem) + { + systemCount++; + } + } + + Assert.That(raceCount, Is.EqualTo(1)); + Assert.That(systemCount, Is.EqualTo(1)); + } + + [Test()] + public void TestFactoryHandlesMultipleFilesWithMultipleNewNamesInOneSystemZip() + { + EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader(); + WarFoundryLoader.SetDefault(loader); + WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); + loader.RegisterFactory(factory); + ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Multipack.system")); + Assert.That(objs, Has.Count(4)); + int raceCount = 0; + int systemCount = 0; + + foreach (IWarFoundryObject obj in objs) + { + if (obj is Race) + { + raceCount++; + } + else if (obj is GameSystem) + { + systemCount++; + } + } + + Assert.That(raceCount, Is.EqualTo(2)); + Assert.That(systemCount, Is.EqualTo(2)); + } } }