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 wrap: on
line diff
--- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Mar 14 17:11:13 2009 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Mar 15 15:21:58 2009 +0000
@@ -40,8 +40,7 @@
     <Content Include="libs\ICSharpCode.SharpZipLib.dll" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="MockObjects\FixedFileWarFoundryLoader.cs" />
-    <Compile Include="MockObjects\MockFactory.cs" />
+    <Compile Include="MockObjects\MockSystemFactory.cs" />
     <Compile Include="MockObjects\MockRaceZipFile.cs" />
     <Compile Include="MockObjects\MockSystemZipFile.cs" />
     <Compile Include="WarFoundryFactoryFactoryTest.cs" />
--- a/MockObjects/FixedFileWarFoundryLoader.cs	Sat Mar 14 17:11:13 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-// This file (FixedFileWarFoundryLoader.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
-//
-// 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.
-
-using System;
-using System.IO;
-using ICSharpCode.SharpZipLib.Zip;
-
-namespace IBBoard.WarFoundry.API
-{
-	public class FixedFileWarFoundryLoader : WarFoundryLoader
-	{
-		private ZipFile zipFile;
-		
-		public FixedFileWarFoundryLoader(ZipFile zip)
-		{
-			zipFile = zip;
-		}
-	}
-}
--- a/MockObjects/MockFactory.cs	Sat Mar 14 17:11:13 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-// This file (MockFactory.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
-//
-// 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.
-
-using System;
-using System.IO;
-using IBBoard.WarFoundry.API.Objects;
-using ICSharpCode.SharpZipLib.Zip;
-
-namespace IBBoard.WarFoundry.API.Factories
-{
-	public class MockFactory : AbstractNativeWarFoundryFactory
-	{		
-		public MockFactory()
-		{
-		}
-		
-		protected override bool CheckCanFindArmyFileContent(ZipFile file)
-		{
-			return true;
-		}
-		
-		protected override bool CheckCanFindRaceFileContent(ZipFile file)
-		{
-			return true;
-		}
-		
-		protected override bool CheckCanFindSystemFileContent(ZipFile file)
-		{
-			return true;
-		}
-		
-		protected override Army CreateArmyFromStream (ZipFile file, Stream dataStream)
-		{
-			throw new NotImplementedException ();
-		}
-		
-		protected override GameSystem CreateGameSystemFromStream (ZipFile file, Stream dataStream)
-		{
-			throw new NotImplementedException ();
-		}
-		
-		protected override Race CreateRaceFromStream (ZipFile file, Stream dataStream)
-		{
-			throw new NotImplementedException ();
-		}
-		
-		protected override Stream GetArmyDataStream (ZipFile file)
-		{
-			throw new NotImplementedException ();
-		}
-		
-		protected override Stream GetGameSystemDataStream (ZipFile file)
-		{
-			throw new NotImplementedException ();
-		}
-
-		protected override Stream GetRaceDataStream (ZipFile file)
-		{
-			throw new NotImplementedException ();
-		}
-	}
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MockObjects/MockSystemFactory.cs	Sun Mar 15 15:21:58 2009 +0000
@@ -0,0 +1,63 @@
+// This file (MockSystemFactory.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
+//
+// 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.
+
+using System;
+using System.IO;
+using IBBoard.WarFoundry.API.Objects;
+using ICSharpCode.SharpZipLib.Zip;
+
+namespace IBBoard.WarFoundry.API.Factories
+{
+	public class MockSystemFactory : AbstractNativeWarFoundryFactory
+	{		
+		public MockSystemFactory()
+		{
+		}
+		
+		protected override bool CheckCanFindArmyFileContent(ZipFile file)
+		{
+			return false;
+		}
+		
+		protected override bool CheckCanFindRaceFileContent(ZipFile file)
+		{
+			return false;
+		}
+		
+		protected override bool CheckCanFindSystemFileContent(ZipFile file)
+		{
+			return true;
+		}
+		
+		protected override Army CreateArmyFromStream (ZipFile file, Stream dataStream)
+		{
+			throw new NotImplementedException ();
+		}
+		
+		protected override GameSystem CreateGameSystemFromStream (ZipFile file, Stream dataStream)
+		{
+			return new GameSystem("test", "Test System", this);
+		}
+		
+		protected override Race CreateRaceFromStream (ZipFile file, Stream dataStream)
+		{
+			throw new NotImplementedException ();
+		}
+		
+		protected override Stream GetArmyDataStream (ZipFile file)
+		{
+			throw new NotImplementedException ();
+		}
+		
+		protected override Stream GetGameSystemDataStream (ZipFile file)
+		{
+			return new MemoryStream();
+		}
+
+		protected override Stream GetRaceDataStream (ZipFile file)
+		{
+			throw new NotImplementedException ();
+		}
+	}
+}
--- a/WarFoundryLoaderTest.cs	Sat Mar 14 17:11:13 2009 +0000
+++ b/WarFoundryLoaderTest.cs	Sun Mar 15 15:21:58 2009 +0000
@@ -6,13 +6,14 @@
 using System.IO;
 using NUnit.Framework;
 using IBBoard.WarFoundry.API.Objects;
+using IBBoard.WarFoundry.API.Factories.Xml;
 
 namespace IBBoard.WarFoundry.API.Factories
 {
 	[TestFixture()]
 	public class WarFoundryLoaderTest
 	{
-		private AbstractNativeWarFoundryFactory factory;
+		private AbstractNativeWarFoundryFactory sysFactory;
 				
 		[Test()]
 		public void TestLoadWithoutFactoriesCompletesWithoutError()
@@ -23,34 +24,24 @@
 		[Test()]
 		public void TestLoadingSystemCompletesWithoutError()
 		{
-			WarFoundryLoader loader = GetSystemLoader();
-			DirectoryInfo dir = new DirectoryInfo(".");
-			loader.RegisterFactory(GetFactory());
+			WarFoundryLoader loader = WarFoundryLoader.GetDefault();
+			DirectoryInfo dir = new DirectoryInfo("testdata");
+			loader.RegisterFactory(GetSystemFactory());
 			loader.AddLoadDirectory(dir);
 			loader.LoadFiles();
 			Assert.Greater(loader.GetGameSystems().Length, 0);
 			loader.RemoveLoadDirectory(dir);
-			loader.UnregisterFactory(GetFactory());
+			loader.UnregisterFactory(GetSystemFactory());
 		}
 				
-		private AbstractNativeWarFoundryFactory GetFactory()
+		private AbstractNativeWarFoundryFactory GetSystemFactory()
 		{
-			if (factory == null)
+			if (sysFactory == null)
 			{
-				factory = new MockFactory();
+				sysFactory = new MockSystemFactory();
 			}
 			
-			return factory;
-		}
-		
-		private WarFoundryLoader GetSystemLoader()
-		{
-			return new FixedFileWarFoundryLoader(new MockSystemZipFile());
-		}
-		
-		private WarFoundryLoader GetRaceLoader()
-		{
-			return new FixedFileWarFoundryLoader(new MockRaceZipFile());
+			return sysFactory;
 		}
 	}
 }
Binary file testdata/Test.race has changed
Binary file testdata/Test.system has changed