changeset 87:5c04db41d643

Re #253: Allow multiple data files in a single zip * Add test data and initial test
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Feb 2011 20:14:29 +0000
parents d1ec7618f812
children 31fd34f7d7cf
files API/Factories/Xml/WarFoundryXmlFactoryTests.cs IBBoard.WarFoundry.API.Tests.csproj testdata/multifile-zips/Multipack.system testdata/multifile-zips/Test.race testdata/multifile-zips/Test.system
diffstat 5 files changed, 52 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlFactoryTests.cs	Sat Feb 26 20:14:29 2011 +0000
     1.3 @@ -0,0 +1,37 @@
     1.4 +using System;
     1.5 +using NUnit.Framework;
     1.6 +using System.IO;
     1.7 +using System.Collections.Generic;
     1.8 +using IBBoard.WarFoundry.API.Objects;
     1.9 +using NUnit.Framework.SyntaxHelpers;
    1.10 +
    1.11 +namespace IBBoard.WarFoundry.API.Factories.Xml
    1.12 +{
    1.13 +	[TestFixture()]
    1.14 +	public class WarFoundryXmlFactoryTests
    1.15 +	{
    1.16 +		[Test()]
    1.17 +		public void TestFactoryHandlesMultipleFilesWithOldNamesInOneSystemZip()
    1.18 +		{
    1.19 +			ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.system"));
    1.20 +			Assert.That(objs, Has.Count(2));
    1.21 +			int raceCount = 0;
    1.22 +			int systemCount = 0;
    1.23 +			
    1.24 +			foreach (IWarFoundryObject obj in objs)
    1.25 +			{
    1.26 +				if (obj is Race)
    1.27 +				{
    1.28 +					raceCount++;
    1.29 +				}
    1.30 +				else if (obj is GameSystem)
    1.31 +				{
    1.32 +					systemCount++;
    1.33 +				}
    1.34 +			}
    1.35 +			
    1.36 +			Assert.That(raceCount, Is.EqualTo(1));
    1.37 +			Assert.That(systemCount, Is.EqualTo(1));
    1.38 +		}
    1.39 +	}
    1.40 +}
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Wed Feb 23 20:37:59 2011 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sat Feb 26 20:14:29 2011 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4 -<?xml version="1.0" encoding="utf-8"?>
     2.5 -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
     2.6 +<?xml version="1.0" encoding="utf-8"?>
     2.7 +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     2.8    <PropertyGroup>
     2.9      <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    2.10      <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    2.11 @@ -88,6 +88,7 @@
    2.12      <Compile Include="MockObjects\MockWarFoundryLoader.cs" />
    2.13      <Compile Include="API\AbstractWarFoundryLoaderTests.cs" />
    2.14      <Compile Include="API\Objects\GameSystemTest.cs" />
    2.15 +    <Compile Include="API\Factories\Xml\WarFoundryXmlFactoryTests.cs" />
    2.16    </ItemGroup>
    2.17    <ItemGroup>
    2.18      <None Include="app.config" />
    2.19 @@ -264,6 +265,15 @@
    2.20        <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
    2.21        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.22      </None>
    2.23 +    <None Include="testdata\multifile-zips\Multipack.system">
    2.24 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.25 +    </None>
    2.26 +    <None Include="testdata\multifile-zips\Test.race">
    2.27 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.28 +    </None>
    2.29 +    <None Include="testdata\multifile-zips\Test.system">
    2.30 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.31 +    </None>
    2.32    </ItemGroup>
    2.33    <ItemGroup>
    2.34      <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
    2.35 @@ -325,4 +335,7 @@
    2.36        <Install>true</Install>
    2.37      </BootstrapperPackage>
    2.38    </ItemGroup>
    2.39 +  <ItemGroup>
    2.40 +    <Folder Include="testdata\multifile-zips\" />
    2.41 +  </ItemGroup>
    2.42  </Project>
    2.43 \ No newline at end of file
     3.1 Binary file testdata/multifile-zips/Multipack.system has changed
     4.1 Binary file testdata/multifile-zips/Test.race has changed
     5.1 Binary file testdata/multifile-zips/Test.system has changed