changeset 9:f96169484ba5

Fixes #44 - Fix API tests * Rename MockFactory to MockSystemFactory * Update test Race and System files * Update broken test to match current load methods * Remove unused "FixedFileWarFoundryLoader" that isn't applicable to new load method
author IBBoard <dev@ibboard.co.uk>
date Sun, 15 Mar 2009 15:21:58 +0000
parents 69bf7972c9fd
children ad8f0bf1f894
files IBBoard.WarFoundry.API.Tests.csproj MockObjects/FixedFileWarFoundryLoader.cs MockObjects/MockFactory.cs MockObjects/MockSystemFactory.cs WarFoundryLoaderTest.cs testdata/Test.race testdata/Test.system
diffstat 7 files changed, 74 insertions(+), 104 deletions(-) [+]
line diff
     1.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Mar 14 17:11:13 2009 +0000
     1.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Mar 15 15:21:58 2009 +0000
     1.3 @@ -40,8 +40,7 @@
     1.4      <Content Include="libs\ICSharpCode.SharpZipLib.dll" />
     1.5    </ItemGroup>
     1.6    <ItemGroup>
     1.7 -    <Compile Include="MockObjects\FixedFileWarFoundryLoader.cs" />
     1.8 -    <Compile Include="MockObjects\MockFactory.cs" />
     1.9 +    <Compile Include="MockObjects\MockSystemFactory.cs" />
    1.10      <Compile Include="MockObjects\MockRaceZipFile.cs" />
    1.11      <Compile Include="MockObjects\MockSystemZipFile.cs" />
    1.12      <Compile Include="WarFoundryFactoryFactoryTest.cs" />
     2.1 --- a/MockObjects/FixedFileWarFoundryLoader.cs	Sat Mar 14 17:11:13 2009 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,20 +0,0 @@
     2.4 -// This file (FixedFileWarFoundryLoader.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
     2.5 -//
     2.6 -// The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
     2.7 -
     2.8 -using System;
     2.9 -using System.IO;
    2.10 -using ICSharpCode.SharpZipLib.Zip;
    2.11 -
    2.12 -namespace IBBoard.WarFoundry.API
    2.13 -{
    2.14 -	public class FixedFileWarFoundryLoader : WarFoundryLoader
    2.15 -	{
    2.16 -		private ZipFile zipFile;
    2.17 -		
    2.18 -		public FixedFileWarFoundryLoader(ZipFile zip)
    2.19 -		{
    2.20 -			zipFile = zip;
    2.21 -		}
    2.22 -	}
    2.23 -}
     3.1 --- a/MockObjects/MockFactory.cs	Sat Mar 14 17:11:13 2009 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,63 +0,0 @@
     3.4 -// This file (MockFactory.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
     3.5 -//
     3.6 -// The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
     3.7 -
     3.8 -using System;
     3.9 -using System.IO;
    3.10 -using IBBoard.WarFoundry.API.Objects;
    3.11 -using ICSharpCode.SharpZipLib.Zip;
    3.12 -
    3.13 -namespace IBBoard.WarFoundry.API.Factories
    3.14 -{
    3.15 -	public class MockFactory : AbstractNativeWarFoundryFactory
    3.16 -	{		
    3.17 -		public MockFactory()
    3.18 -		{
    3.19 -		}
    3.20 -		
    3.21 -		protected override bool CheckCanFindArmyFileContent(ZipFile file)
    3.22 -		{
    3.23 -			return true;
    3.24 -		}
    3.25 -		
    3.26 -		protected override bool CheckCanFindRaceFileContent(ZipFile file)
    3.27 -		{
    3.28 -			return true;
    3.29 -		}
    3.30 -		
    3.31 -		protected override bool CheckCanFindSystemFileContent(ZipFile file)
    3.32 -		{
    3.33 -			return true;
    3.34 -		}
    3.35 -		
    3.36 -		protected override Army CreateArmyFromStream (ZipFile file, Stream dataStream)
    3.37 -		{
    3.38 -			throw new NotImplementedException ();
    3.39 -		}
    3.40 -		
    3.41 -		protected override GameSystem CreateGameSystemFromStream (ZipFile file, Stream dataStream)
    3.42 -		{
    3.43 -			throw new NotImplementedException ();
    3.44 -		}
    3.45 -		
    3.46 -		protected override Race CreateRaceFromStream (ZipFile file, Stream dataStream)
    3.47 -		{
    3.48 -			throw new NotImplementedException ();
    3.49 -		}
    3.50 -		
    3.51 -		protected override Stream GetArmyDataStream (ZipFile file)
    3.52 -		{
    3.53 -			throw new NotImplementedException ();
    3.54 -		}
    3.55 -		
    3.56 -		protected override Stream GetGameSystemDataStream (ZipFile file)
    3.57 -		{
    3.58 -			throw new NotImplementedException ();
    3.59 -		}
    3.60 -
    3.61 -		protected override Stream GetRaceDataStream (ZipFile file)
    3.62 -		{
    3.63 -			throw new NotImplementedException ();
    3.64 -		}
    3.65 -	}
    3.66 -}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/MockObjects/MockSystemFactory.cs	Sun Mar 15 15:21:58 2009 +0000
     4.3 @@ -0,0 +1,63 @@
     4.4 +// This file (MockSystemFactory.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
     4.5 +//
     4.6 +// The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
     4.7 +
     4.8 +using System;
     4.9 +using System.IO;
    4.10 +using IBBoard.WarFoundry.API.Objects;
    4.11 +using ICSharpCode.SharpZipLib.Zip;
    4.12 +
    4.13 +namespace IBBoard.WarFoundry.API.Factories
    4.14 +{
    4.15 +	public class MockSystemFactory : AbstractNativeWarFoundryFactory
    4.16 +	{		
    4.17 +		public MockSystemFactory()
    4.18 +		{
    4.19 +		}
    4.20 +		
    4.21 +		protected override bool CheckCanFindArmyFileContent(ZipFile file)
    4.22 +		{
    4.23 +			return false;
    4.24 +		}
    4.25 +		
    4.26 +		protected override bool CheckCanFindRaceFileContent(ZipFile file)
    4.27 +		{
    4.28 +			return false;
    4.29 +		}
    4.30 +		
    4.31 +		protected override bool CheckCanFindSystemFileContent(ZipFile file)
    4.32 +		{
    4.33 +			return true;
    4.34 +		}
    4.35 +		
    4.36 +		protected override Army CreateArmyFromStream (ZipFile file, Stream dataStream)
    4.37 +		{
    4.38 +			throw new NotImplementedException ();
    4.39 +		}
    4.40 +		
    4.41 +		protected override GameSystem CreateGameSystemFromStream (ZipFile file, Stream dataStream)
    4.42 +		{
    4.43 +			return new GameSystem("test", "Test System", this);
    4.44 +		}
    4.45 +		
    4.46 +		protected override Race CreateRaceFromStream (ZipFile file, Stream dataStream)
    4.47 +		{
    4.48 +			throw new NotImplementedException ();
    4.49 +		}
    4.50 +		
    4.51 +		protected override Stream GetArmyDataStream (ZipFile file)
    4.52 +		{
    4.53 +			throw new NotImplementedException ();
    4.54 +		}
    4.55 +		
    4.56 +		protected override Stream GetGameSystemDataStream (ZipFile file)
    4.57 +		{
    4.58 +			return new MemoryStream();
    4.59 +		}
    4.60 +
    4.61 +		protected override Stream GetRaceDataStream (ZipFile file)
    4.62 +		{
    4.63 +			throw new NotImplementedException ();
    4.64 +		}
    4.65 +	}
    4.66 +}
     5.1 --- a/WarFoundryLoaderTest.cs	Sat Mar 14 17:11:13 2009 +0000
     5.2 +++ b/WarFoundryLoaderTest.cs	Sun Mar 15 15:21:58 2009 +0000
     5.3 @@ -6,13 +6,14 @@
     5.4  using System.IO;
     5.5  using NUnit.Framework;
     5.6  using IBBoard.WarFoundry.API.Objects;
     5.7 +using IBBoard.WarFoundry.API.Factories.Xml;
     5.8  
     5.9  namespace IBBoard.WarFoundry.API.Factories
    5.10  {
    5.11  	[TestFixture()]
    5.12  	public class WarFoundryLoaderTest
    5.13  	{
    5.14 -		private AbstractNativeWarFoundryFactory factory;
    5.15 +		private AbstractNativeWarFoundryFactory sysFactory;
    5.16  				
    5.17  		[Test()]
    5.18  		public void TestLoadWithoutFactoriesCompletesWithoutError()
    5.19 @@ -23,34 +24,24 @@
    5.20  		[Test()]
    5.21  		public void TestLoadingSystemCompletesWithoutError()
    5.22  		{
    5.23 -			WarFoundryLoader loader = GetSystemLoader();
    5.24 -			DirectoryInfo dir = new DirectoryInfo(".");
    5.25 -			loader.RegisterFactory(GetFactory());
    5.26 +			WarFoundryLoader loader = WarFoundryLoader.GetDefault();
    5.27 +			DirectoryInfo dir = new DirectoryInfo("testdata");
    5.28 +			loader.RegisterFactory(GetSystemFactory());
    5.29  			loader.AddLoadDirectory(dir);
    5.30  			loader.LoadFiles();
    5.31  			Assert.Greater(loader.GetGameSystems().Length, 0);
    5.32  			loader.RemoveLoadDirectory(dir);
    5.33 -			loader.UnregisterFactory(GetFactory());
    5.34 +			loader.UnregisterFactory(GetSystemFactory());
    5.35  		}
    5.36  				
    5.37 -		private AbstractNativeWarFoundryFactory GetFactory()
    5.38 +		private AbstractNativeWarFoundryFactory GetSystemFactory()
    5.39  		{
    5.40 -			if (factory == null)
    5.41 +			if (sysFactory == null)
    5.42  			{
    5.43 -				factory = new MockFactory();
    5.44 +				sysFactory = new MockSystemFactory();
    5.45  			}
    5.46  			
    5.47 -			return factory;
    5.48 -		}
    5.49 -		
    5.50 -		private WarFoundryLoader GetSystemLoader()
    5.51 -		{
    5.52 -			return new FixedFileWarFoundryLoader(new MockSystemZipFile());
    5.53 -		}
    5.54 -		
    5.55 -		private WarFoundryLoader GetRaceLoader()
    5.56 -		{
    5.57 -			return new FixedFileWarFoundryLoader(new MockRaceZipFile());
    5.58 +			return sysFactory;
    5.59  		}
    5.60  	}
    5.61  }
     6.1 Binary file testdata/Test.race has changed
     7.1 Binary file testdata/Test.system has changed