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 diff
     1.1 --- a/API/EventListeningWarFoundryLoader.cs	Sun Feb 27 19:44:08 2011 +0000
     1.2 +++ b/API/EventListeningWarFoundryLoader.cs	Sun Feb 27 20:33:12 2011 +0000
     1.3 @@ -39,7 +39,7 @@
     1.4  		
     1.5  		protected override void DoStoreRace (Race race)
     1.6  		{
     1.7 -			races.Add(race.ID, race);
     1.8 +			races.Add(race.GameSystem.ID + race.ID, race);
     1.9  		}
    1.10  		
    1.11  		
     2.1 --- a/API/Factories/Xml/WarFoundryXmlFactoryTests.cs	Sun Feb 27 19:44:08 2011 +0000
     2.2 +++ b/API/Factories/Xml/WarFoundryXmlFactoryTests.cs	Sun Feb 27 20:33:12 2011 +0000
     2.3 @@ -13,9 +13,9 @@
     2.4  		[Test()]
     2.5  		public void TestFactoryHandlesMultipleFilesWithOldNamesInOneSystemZip()
     2.6  		{
     2.7 -			EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader ();
     2.8 +			EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader();
     2.9  			WarFoundryLoader.SetDefault(loader);
    2.10 -			WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory ();
    2.11 +			WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory();
    2.12  			loader.RegisterFactory(factory);
    2.13  			ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.system"));
    2.14  			Assert.That(objs, Has.Count(2));
    2.15 @@ -37,5 +37,61 @@
    2.16  			Assert.That(raceCount, Is.EqualTo(1));
    2.17  			Assert.That(systemCount, Is.EqualTo(1));
    2.18  		}
    2.19 +			
    2.20 +		[Test()]
    2.21 +		public void TestFactoryHandlesMultipleFilesWithOldNamesInOneRaceZip()
    2.22 +		{
    2.23 +			EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader();
    2.24 +			WarFoundryLoader.SetDefault(loader);
    2.25 +			WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory();
    2.26 +			loader.RegisterFactory(factory);
    2.27 +			ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.race"));
    2.28 +			Assert.That(objs, Has.Count(2));
    2.29 +			int raceCount = 0;
    2.30 +			int systemCount = 0;
    2.31 +			
    2.32 +			foreach (IWarFoundryObject obj in objs)
    2.33 +			{
    2.34 +				if (obj is Race)
    2.35 +				{
    2.36 +					raceCount++;
    2.37 +				}
    2.38 +				else if (obj is GameSystem)
    2.39 +				{
    2.40 +					systemCount++;
    2.41 +				}
    2.42 +			}
    2.43 +			
    2.44 +			Assert.That(raceCount, Is.EqualTo(1));
    2.45 +			Assert.That(systemCount, Is.EqualTo(1));
    2.46 +		}
    2.47 +		
    2.48 +		[Test()]
    2.49 +		public void TestFactoryHandlesMultipleFilesWithMultipleNewNamesInOneSystemZip()
    2.50 +		{
    2.51 +			EventListeningWarFoundryLoader loader = new EventListeningWarFoundryLoader();
    2.52 +			WarFoundryLoader.SetDefault(loader);
    2.53 +			WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory();
    2.54 +			loader.RegisterFactory(factory);
    2.55 +			ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Multipack.system"));
    2.56 +			Assert.That(objs, Has.Count(4));
    2.57 +			int raceCount = 0;
    2.58 +			int systemCount = 0;
    2.59 +			
    2.60 +			foreach (IWarFoundryObject obj in objs)
    2.61 +			{
    2.62 +				if (obj is Race)
    2.63 +				{
    2.64 +					raceCount++;
    2.65 +				}
    2.66 +				else if (obj is GameSystem)
    2.67 +				{
    2.68 +					systemCount++;
    2.69 +				}
    2.70 +			}
    2.71 +			
    2.72 +			Assert.That(raceCount, Is.EqualTo(2));
    2.73 +			Assert.That(systemCount, Is.EqualTo(2));
    2.74 +		}
    2.75  	}
    2.76  }