changeset 75:72479ca6feb4

Fixes #311: can't read ZIP file packed by Linux app Archive Manager/File Roller * Add a unit test for the failure
author IBBoard <dev@ibboard.co.uk>
date Sat, 30 Oct 2010 14:45:45 +0000
parents 5bf51f7a28ce
children fb60ff2002fd
files API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sat Oct 30 14:27:20 2010 +0000
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sat Oct 30 14:45:45 2010 +0000
     1.3 @@ -1,6 +1,7 @@
     1.4  //  This file (WarFoundryXmlSystemFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2010 IBBoard
     1.5  // 
     1.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.
     1.7 +
     1.8  using System;
     1.9  using NUnit.Framework;
    1.10  using System.IO;
    1.11 @@ -15,6 +16,14 @@
    1.12  	public class WarFoundryXmlSystemFactoryTest
    1.13  	{
    1.14  		[Test()]
    1.15 +		public void TestBug311InvalidVersionToExtract788()
    1.16 +		{
    1.17 +			FileInfo repackFile = new FileInfo("testdata/zip-format/Repack.system");
    1.18 +			Assert.That(WarFoundryXmlFactory.GetFactory().CanHandleFileAsGameSystem(repackFile), Is.True);
    1.19 +			Assert.That(WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(repackFile), Has.Count(1));
    1.20 +		}
    1.21 +
    1.22 +		[Test()]
    1.23  		public void TestGettingDefaultStatsIDFullyLoadsGameSystem()
    1.24  		{
    1.25  			GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx"));
    1.26 @@ -24,7 +33,7 @@
    1.27  			Assert.That(defaultStatsID, Is.Not.Empty);
    1.28  			Assert.That(system.IsFullyLoaded, Is.True);
    1.29  		}
    1.30 -		
    1.31 +
    1.32  		[Test()]
    1.33  		public void TestValidDefaultStatsIDLoadsCorrectly()
    1.34  		{
    1.35 @@ -32,7 +41,7 @@
    1.36  			Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats"));
    1.37  			Assert.That(system.SystemStats, Has.Length(1));
    1.38  		}
    1.39 -		
    1.40 +
    1.41  		[Test()]
    1.42  		public void TestValidDefaultStatsIDLoadsCorrectlyWithMultipleStatsSets()
    1.43  		{
    1.44 @@ -40,32 +49,32 @@
    1.45  			Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats"));
    1.46  			Assert.That(system.SystemStats, Has.Length(2));
    1.47  		}
    1.48 -		
    1.49 +
    1.50  		[Test()]
    1.51  		public void TestIncorrectDefaultStatsIDErrors()
    1.52  		{
    1.53  			TestFileValidationFailure("testdata/xml-system-factory/invalid-default-stats.systemx");
    1.54  		}
    1.55 -		
    1.56 +
    1.57  		[Test()]
    1.58  		public void TestDuplicateStatsIDErrors()
    1.59  		{
    1.60  			TestFileValidationFailure("testdata/xml-system-factory/duplicate-stats-set-id.systemx");
    1.61  		}
    1.62 -		
    1.63 +
    1.64  		[Test()]
    1.65  		public void TestValidCategoriesLoadsCorrectly()
    1.66  		{
    1.67  			GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-categories.systemx"));
    1.68  			Assert.That(system.Categories, Has.Length(5));
    1.69  		}	
    1.70 -		
    1.71 +
    1.72  		[Test()]
    1.73  		public void TestDuplicateCategoryIDErrors()
    1.74  		{
    1.75  			TestFileValidationFailure("testdata/xml-system-factory/duplicate-category-ids.systemx");
    1.76  		}
    1.77 -		
    1.78 +
    1.79  		private void TestFileValidationFailure(string filePath)
    1.80  		{
    1.81  			FileInfo systemFile = new FileInfo(filePath);
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Oct 30 14:27:20 2010 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sat Oct 30 14:45:45 2010 +0000
     2.3 @@ -231,6 +231,9 @@
     2.4      <None Include="testdata\xml-race-factory\duplicate-category-ids.racex">
     2.5        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     2.6      </None>
     2.7 +    <None Include="testdata\zip-format\Repack.system">
     2.8 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     2.9 +    </None>
    2.10    </ItemGroup>
    2.11    <ItemGroup>
    2.12      <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />