changeset 196:498396c77601

Re #380: WarFoundry chokes on zips written by Mac OS X * Add test to check that entries are found but skipped for loading * Add mock file that extends the standard XML factory to give us public access to protected methods
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Dec 2011 20:52:24 +0000
parents 8e95ccb8e9d5
children aa921248ffbf
files API/Factories/AbstractNativeWarFoundryFactoryTest.cs API/Factories/Mock/FileSearchingWarFoundryFactory.cs IBBoard.WarFoundry.API.Tests.csproj testdata/multifile-zips/Test-OSX-style.system
diffstat 4 files changed, 57 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Factories/AbstractNativeWarFoundryFactoryTest.cs	Sat Dec 03 20:09:25 2011 +0000
     1.2 +++ b/API/Factories/AbstractNativeWarFoundryFactoryTest.cs	Sun Dec 04 20:52:24 2011 +0000
     1.3 @@ -7,6 +7,8 @@
     1.4  using System.Diagnostics;
     1.5  using NUnit.Framework.SyntaxHelpers;
     1.6  using System.IO;
     1.7 +using IBBoard.WarFoundry.API.Objects;
     1.8 +using System.Collections.Generic;
     1.9  
    1.10  namespace IBBoard.WarFoundry.API.Factories
    1.11  {
    1.12 @@ -39,6 +41,18 @@
    1.13  			Assert.That(nonRaceFile.Exists, Is.True);
    1.14  			Assert.That(factory.CanHandleFileFormat(nonRaceFile), Is.False);
    1.15  		}
    1.16 +
    1.17 +		[Test]
    1.18 +		public void Bug380TestLoadingOfOSXesqueFile()
    1.19 +		{
    1.20 +			FileSearchingWarFoundryFactory factory = new FileSearchingWarFoundryFactory();
    1.21 +			FileInfo file = new FileInfo("testdata/multifile-zips/Test-OSX-style.system");
    1.22 +			Assert.That(factory.GetGameSystemZipEntries(file), Has.Count(3));
    1.23 +			Assert.That(factory.GetRaceZipEntries(file), Has.Count(3));
    1.24 +			Assert.That(factory.GetArmyZipEntries(file), Has.Count(3));
    1.25 +			ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(file);
    1.26 +			Assert.That(objs, Has.Count(0));
    1.27 +		}
    1.28  	}
    1.29  }
    1.30  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/API/Factories/Mock/FileSearchingWarFoundryFactory.cs	Sun Dec 04 20:52:24 2011 +0000
     2.3 @@ -0,0 +1,39 @@
     2.4 +// This file (FileSearchingWarFoundryFactory.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
     2.5 +// 
     2.6 +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
     2.7 +using System;
     2.8 +using System.Collections.Generic;
     2.9 +using ICSharpCode.SharpZipLib.Zip;
    2.10 +using IBBoard.WarFoundry.API.Factories.Xml;
    2.11 +using System.IO;
    2.12 +using IBBoard.WarFoundry.API.Objects;
    2.13 +
    2.14 +namespace IBBoard.WarFoundry.API.Factories.Mock
    2.15 +{
    2.16 +	public class FileSearchingWarFoundryFactory : WarFoundryXmlFactory
    2.17 +	{
    2.18 +		public FileSearchingWarFoundryFactory()
    2.19 +		{
    2.20 +			//Do nothing special
    2.21 +		}
    2.22 +
    2.23 +		public ICollection<ZipEntry> GetGameSystemZipEntries(FileInfo file)
    2.24 +		{
    2.25 +			ZipFile zip = new ZipFile(file.FullName);
    2.26 +			return GetGameSystemZipEntries(zip);
    2.27 +		}
    2.28 +
    2.29 +		public ICollection<ZipEntry> GetRaceZipEntries(FileInfo file)
    2.30 +		{
    2.31 +			ZipFile zip = new ZipFile(file.FullName);
    2.32 +			return GetRaceZipEntries(zip);
    2.33 +		}
    2.34 +
    2.35 +		public ICollection<ZipEntry> GetArmyZipEntries(FileInfo file)
    2.36 +		{
    2.37 +			ZipFile zip = new ZipFile(file.FullName);
    2.38 +			return GetArmyZipEntries(zip);
    2.39 +		}
    2.40 +	}
    2.41 +}
    2.42 +
     3.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Dec 03 20:09:25 2011 +0000
     3.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Dec 04 20:52:24 2011 +0000
     3.3 @@ -115,6 +115,7 @@
     3.4      <Compile Include="API\Factories\Requirement\UnitRequiresNoMoreThanNOfUnitTypeRequirementFactoryTest.cs" />
     3.5      <Compile Include="API\Objects\Requirement\RequiresNUnitsForMUnitsRequirementTest.cs" />
     3.6      <Compile Include="API\Factories\Requirement\UnitRequiresNUnitsForMUnitsRequirementFactoryTest.cs" />
     3.7 +    <Compile Include="API\Factories\Mock\FileSearchingWarFoundryFactory.cs" />
     3.8    </ItemGroup>
     3.9    <ItemGroup>
    3.10      <None Include="app.config" />
    3.11 @@ -310,6 +311,9 @@
    3.12        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    3.13      </Content>
    3.14      <None Include="libs\xmlunit.dll" />
    3.15 +    <None Include="testdata\multifile-zips\Test-OSX-style.system">
    3.16 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    3.17 +    </None>
    3.18    </ItemGroup>
    3.19    <ItemGroup>
    3.20      <Reference Include="System" />
     4.1 Binary file testdata/multifile-zips/Test-OSX-style.system has changed