changeset 77:4211c818ef96

Fixes #238: subfolders datafolder * Add unit test and mock object to test loading from sub-folders. We use any old file because it will fail to load it and report a failure without relying on loading logic.
author IBBoard <dev@ibboard.co.uk>
date Tue, 25 Jan 2011 21:04:25 +0000
parents fb60ff2002fd
children 8d3827de003d
files API/AbstractWarFoundryLoaderTests.cs IBBoard.WarFoundry.API.Tests.csproj MockObjects/MockWarFoundryLoader.cs testdata/subdir-loading-test/emptyfile.txt testdata/subdir-loading-test/subdir/subdirfile.txt
diffstat 5 files changed, 102 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/API/AbstractWarFoundryLoaderTests.cs	Tue Jan 25 21:04:25 2011 +0000
     1.3 @@ -0,0 +1,23 @@
     1.4 +using System;
     1.5 +using NUnit.Framework;
     1.6 +using IBBoard.WarFoundry.MockObjects;
     1.7 +using System.Collections.Generic;
     1.8 +using NUnit.Framework.SyntaxHelpers;
     1.9 +using System.IO;
    1.10 +
    1.11 +namespace IBBoard.WarFoundry.API
    1.12 +{
    1.13 +	[TestFixture()]
    1.14 +	public class AbstractWarFoundryLoaderTests
    1.15 +	{
    1.16 +		[Test()]
    1.17 +		public void TestTriesToLoadFromSubdir()
    1.18 +		{
    1.19 +			MockWarFoundryLoader loader = new MockWarFoundryLoader();
    1.20 +			loader.AddLoadDirectory(new DirectoryInfo("testdata/subdir-loading-test"));
    1.21 +			List<FileLoadFailure> failures = loader.LoadFiles ();
    1.22 +			Assert.That(failures.Count, Is.EqualTo(2));
    1.23 +		}
    1.24 +	}
    1.25 +}
    1.26 +
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Oct 30 14:46:06 2010 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Tue Jan 25 21:04:25 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 @@ -15,7 +15,6 @@
    2.12      <UpgradeBackupLocation>
    2.13      </UpgradeBackupLocation>
    2.14      <OldToolsVersion>2.0</OldToolsVersion>
    2.15 -    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    2.16      <TargetFrameworkSubset>
    2.17      </TargetFrameworkSubset>
    2.18    </PropertyGroup>
    2.19 @@ -70,6 +69,8 @@
    2.20      <Compile Include="API\FixedObjectWarFoundryLoader.cs" />
    2.21      <Compile Include="API\Factories\Xml\WarFoundryXmlLimitParserTest.cs" />
    2.22      <Compile Include="API\Factories\Xml\WarFoundryXmlSystemFactoryTest.cs" />
    2.23 +    <Compile Include="MockObjects\MockWarFoundryLoader.cs" />
    2.24 +    <Compile Include="API\AbstractWarFoundryLoaderTests.cs" />
    2.25    </ItemGroup>
    2.26    <ItemGroup>
    2.27      <None Include="app.config" />
    2.28 @@ -122,7 +123,9 @@
    2.29      <None Include="testdata\single-unit-two-categories.racex">
    2.30        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.31      </None>
    2.32 -    <None Include="testdata\unit-in-non-main-category.armyx" />
    2.33 +    <None Include="testdata\unit-in-non-main-category.armyx">
    2.34 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.35 +    </None>
    2.36      <None Include="testdata\unit-in-default-category.armyx">
    2.37        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.38      </None>
    2.39 @@ -234,6 +237,12 @@
    2.40      <None Include="testdata\zip-format\Repack.system">
    2.41        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.42      </None>
    2.43 +    <None Include="testdata\subdir-loading-test\emptyfile.txt">
    2.44 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.45 +    </None>
    2.46 +    <None Include="testdata\subdir-loading-test\subdir\subdirfile.txt">
    2.47 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.48 +    </None>
    2.49    </ItemGroup>
    2.50    <ItemGroup>
    2.51      <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
    2.52 @@ -263,4 +272,8 @@
    2.53      </MonoDevelop>
    2.54      <VisualStudio />
    2.55    </ProjectExtensions>
    2.56 +  <ItemGroup>
    2.57 +    <Folder Include="testdata\subdir-loading-test\" />
    2.58 +    <Folder Include="testdata\subdir-loading-test\subdir\" />
    2.59 +  </ItemGroup>
    2.60  </Project>
    2.61 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/MockObjects/MockWarFoundryLoader.cs	Tue Jan 25 21:04:25 2011 +0000
     3.3 @@ -0,0 +1,60 @@
     3.4 +using System;
     3.5 +using IBBoard.WarFoundry.API;
     3.6 +using IBBoard.WarFoundry.API.Objects;
     3.7 +
     3.8 +namespace IBBoard.WarFoundry.MockObjects
     3.9 +{
    3.10 +	public class MockWarFoundryLoader : AbstractWarFoundryLoader
    3.11 +	{
    3.12 +		protected override GameSystem GetExistingSystemForSystem(GameSystem system)
    3.13 +		{
    3.14 +			return system;
    3.15 +		}
    3.16 +
    3.17 +		protected override void DoStoreGameSystem(GameSystem system)
    3.18 +		{
    3.19 +			//Do nothing
    3.20 +		}
    3.21 +
    3.22 +		protected override void DoStoreRace(Race race)
    3.23 +		{
    3.24 +			//Do nothing
    3.25 +		}
    3.26 +
    3.27 +		public override GameSystem[] GetGameSystems()
    3.28 +		{
    3.29 +			return new GameSystem[0];
    3.30 +		}
    3.31 +
    3.32 +		public override GameSystem GetGameSystem(string systemID)
    3.33 +		{
    3.34 +			return null;
    3.35 +		}
    3.36 +
    3.37 +		protected override void RemoveGameSystem(GameSystem system)
    3.38 +		{
    3.39 +			//Do nothing
    3.40 +		}
    3.41 +
    3.42 +		public override Race[] GetRaces(GameSystem system)
    3.43 +		{
    3.44 +			return new Race[0];
    3.45 +		}
    3.46 +
    3.47 +		public override Race GetRace(GameSystem system, string raceID)
    3.48 +		{
    3.49 +			return null;
    3.50 +		}
    3.51 +
    3.52 +		public override Race GetRace(GameSystem system, string raceID, string raceSubID)
    3.53 +		{
    3.54 +			return null;
    3.55 +		}
    3.56 +
    3.57 +		protected override void RemoveRace(Race race)
    3.58 +		{
    3.59 +			//Do nothing
    3.60 +		}
    3.61 +	}
    3.62 +}
    3.63 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/testdata/subdir-loading-test/emptyfile.txt	Tue Jan 25 21:04:25 2011 +0000
     4.3 @@ -0,0 +1,1 @@
     4.4 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/testdata/subdir-loading-test/subdir/subdirfile.txt	Tue Jan 25 21:04:25 2011 +0000
     5.3 @@ -0,0 +1,1 @@
     5.4 +