# HG changeset patch # User IBBoard # Date 1323031944 0 # Node ID 498396c77601496b9a42ad01b290b5e850fe1599 # Parent 8e95ccb8e9d5500b15bd8741ce17719fc8ca631c 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 diff -r 8e95ccb8e9d5 -r 498396c77601 API/Factories/AbstractNativeWarFoundryFactoryTest.cs --- a/API/Factories/AbstractNativeWarFoundryFactoryTest.cs Sat Dec 03 20:09:25 2011 +0000 +++ b/API/Factories/AbstractNativeWarFoundryFactoryTest.cs Sun Dec 04 20:52:24 2011 +0000 @@ -7,6 +7,8 @@ using System.Diagnostics; using NUnit.Framework.SyntaxHelpers; using System.IO; +using IBBoard.WarFoundry.API.Objects; +using System.Collections.Generic; namespace IBBoard.WarFoundry.API.Factories { @@ -39,6 +41,18 @@ Assert.That(nonRaceFile.Exists, Is.True); Assert.That(factory.CanHandleFileFormat(nonRaceFile), Is.False); } + + [Test] + public void Bug380TestLoadingOfOSXesqueFile() + { + FileSearchingWarFoundryFactory factory = new FileSearchingWarFoundryFactory(); + FileInfo file = new FileInfo("testdata/multifile-zips/Test-OSX-style.system"); + Assert.That(factory.GetGameSystemZipEntries(file), Has.Count(3)); + Assert.That(factory.GetRaceZipEntries(file), Has.Count(3)); + Assert.That(factory.GetArmyZipEntries(file), Has.Count(3)); + ICollection objs = factory.CreateObjectsFromFile(file); + Assert.That(objs, Has.Count(0)); + } } } diff -r 8e95ccb8e9d5 -r 498396c77601 API/Factories/Mock/FileSearchingWarFoundryFactory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Factories/Mock/FileSearchingWarFoundryFactory.cs Sun Dec 04 20:52:24 2011 +0000 @@ -0,0 +1,39 @@ +// This file (FileSearchingWarFoundryFactory.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard +// +// 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. +using System; +using System.Collections.Generic; +using ICSharpCode.SharpZipLib.Zip; +using IBBoard.WarFoundry.API.Factories.Xml; +using System.IO; +using IBBoard.WarFoundry.API.Objects; + +namespace IBBoard.WarFoundry.API.Factories.Mock +{ + public class FileSearchingWarFoundryFactory : WarFoundryXmlFactory + { + public FileSearchingWarFoundryFactory() + { + //Do nothing special + } + + public ICollection GetGameSystemZipEntries(FileInfo file) + { + ZipFile zip = new ZipFile(file.FullName); + return GetGameSystemZipEntries(zip); + } + + public ICollection GetRaceZipEntries(FileInfo file) + { + ZipFile zip = new ZipFile(file.FullName); + return GetRaceZipEntries(zip); + } + + public ICollection GetArmyZipEntries(FileInfo file) + { + ZipFile zip = new ZipFile(file.FullName); + return GetArmyZipEntries(zip); + } + } +} + diff -r 8e95ccb8e9d5 -r 498396c77601 IBBoard.WarFoundry.API.Tests.csproj --- a/IBBoard.WarFoundry.API.Tests.csproj Sat Dec 03 20:09:25 2011 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sun Dec 04 20:52:24 2011 +0000 @@ -115,6 +115,7 @@ + @@ -310,6 +311,9 @@ PreserveNewest + + PreserveNewest + diff -r 8e95ccb8e9d5 -r 498396c77601 testdata/multifile-zips/Test-OSX-style.system Binary file testdata/multifile-zips/Test-OSX-style.system has changed