changeset 67:d3191c44f163

Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Add first system factory tests for stats sets
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Jul 2010 15:05:00 +0000
parents f671ead260b1
children a82f164e26e3
files API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx
diffstat 4 files changed, 98 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sun Jul 04 15:05:00 2010 +0000
     1.3 @@ -0,0 +1,41 @@
     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 +using System;
     1.8 +using NUnit.Framework;
     1.9 +using System.IO;
    1.10 +using IBBoard.WarFoundry.API.Objects;
    1.11 +using NUnit.Framework.SyntaxHelpers;
    1.12 +
    1.13 +namespace IBBoard.WarFoundry.API.Factories.Xml
    1.14 +{
    1.15 +	[TestFixture()]
    1.16 +	public class WarFoundryXmlSystemFactoryTest
    1.17 +	{
    1.18 +		[Test()]
    1.19 +		public void TestGettingDefaultStatsIDFullyLoadsGameSystem()
    1.20 +		{
    1.21 +			GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx"));
    1.22 +			Assert.That(system.IsFullyLoaded, Is.False);
    1.23 +			string temp = system.StandardSystemStatsID;
    1.24 +			Assert.That(system.IsFullyLoaded, Is.True);
    1.25 +		}
    1.26 +		
    1.27 +		[Test()]
    1.28 +		public void TestValidDefaultStatsIDLoadsCorrectly()
    1.29 +		{
    1.30 +			GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx"));
    1.31 +			Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats"));
    1.32 +			Assert.That(system.SystemStats, Has.Length(1));
    1.33 +		}
    1.34 +		
    1.35 +		[Test()]
    1.36 +		public void TestValidDefaultStatsIDLoadsCorrectlyWithMultipleStatsSets()
    1.37 +		{
    1.38 +			GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx"));
    1.39 +			Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats"));
    1.40 +			Assert.That(system.SystemStats, Has.Length(2));
    1.41 +		}
    1.42 +	}
    1.43 +}
    1.44 +
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sun Jul 04 14:28:13 2010 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Jul 04 15:05:00 2010 +0000
     2.3 @@ -64,6 +64,7 @@
     2.4      <Compile Include="API\Factories\Xml\WarFoundryXmlArmyParserTest.cs" />
     2.5      <Compile Include="API\FixedObjectWarFoundryLoader.cs" />
     2.6      <Compile Include="API\Factories\Xml\WarFoundryXmlLimitParserTest.cs" />
     2.7 +    <Compile Include="API\Factories\Xml\WarFoundryXmlSystemFactoryTest.cs" />
     2.8    </ItemGroup>
     2.9    <ItemGroup>
    2.10      <None Include="testdata\Test.race">
    2.11 @@ -191,6 +192,12 @@
    2.12      <None Include="testdata\xml-race-factory\duplicate-equipment-id.racex">
    2.13        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.14      </None>
    2.15 +    <None Include="testdata\xml-system-factory\valid-default-stats-one-stats-set.systemx">
    2.16 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.17 +    </None>
    2.18 +    <None Include="testdata\xml-system-factory\valid-default-stats-multiple-stats-set.systemx">
    2.19 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    2.20 +    </None>
    2.21    </ItemGroup>
    2.22    <ItemGroup>
    2.23      <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
    2.24 @@ -224,5 +231,6 @@
    2.25      <Folder Include="testdata\xml-race-factory\" />
    2.26      <Folder Include="testdata\" />
    2.27      <Folder Include="testdata\" />
    2.28 +    <Folder Include="testdata\xml-system-factory\" />
    2.29    </ItemGroup>
    2.30  </Project>
    2.31 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx	Sun Jul 04 15:05:00 2010 +0000
     3.3 @@ -0,0 +1,26 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<system xmlns="http://ibboard.co.uk/warfoundry/system" xmlns:cats="http://ibboard.co.uk/warfoundry/cats" id="default" name="Default Game System" warn="false">
     3.6 +	<categories>
     3.7 +		<cats:cat id="cat1" name="Characters" minPercentage="0" maxPercentage="50" />
     3.8 +		<cats:cat id="cat2" name="Regiments" minPercentage="25" maxPercentage="100" />
     3.9 +		<cats:cat id="cat3" name="War Machines" minPercentage="0" maxPercentage="25" />
    3.10 +		<cats:cat id="cat4" name="Monsters" minPercentage="0" maxPercentage="25" />
    3.11 +		<cats:cat id="cat5" name="Allies" minPercentage="0" maxPercentage="25" />
    3.12 +	</categories>
    3.13 +	<sysStatsList defaultStats="defaultStats">
    3.14 +		<sysStats id="defaultStats">
    3.15 +			<sysStat name="M"/>
    3.16 +			<sysStat name="WS"/>
    3.17 +			<sysStat name="BS"/>
    3.18 +			<sysStat name="S"/>
    3.19 +			<sysStat name="T"/>
    3.20 +			<sysStat name="W"/>
    3.21 +			<sysStat name="I"/>
    3.22 +			<sysStat name="A"/>
    3.23 +			<sysStat name="Ld"/>
    3.24 +		</sysStats>
    3.25 +		<sysStats id="otherStats">
    3.26 +			<sysStat name="M"/>
    3.27 +		</sysStats>
    3.28 +	</sysStatsList>
    3.29 +</system>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx	Sun Jul 04 15:05:00 2010 +0000
     4.3 @@ -0,0 +1,23 @@
     4.4 +<?xml version="1.0" encoding="UTF-8"?>
     4.5 +<system xmlns="http://ibboard.co.uk/warfoundry/system" xmlns:cats="http://ibboard.co.uk/warfoundry/cats" id="default" name="Default Game System" warn="false">
     4.6 +	<categories>
     4.7 +		<cats:cat id="cat1" name="Characters" minPercentage="0" maxPercentage="50" />
     4.8 +		<cats:cat id="cat2" name="Regiments" minPercentage="25" maxPercentage="100" />
     4.9 +		<cats:cat id="cat3" name="War Machines" minPercentage="0" maxPercentage="25" />
    4.10 +		<cats:cat id="cat4" name="Monsters" minPercentage="0" maxPercentage="25" />
    4.11 +		<cats:cat id="cat5" name="Allies" minPercentage="0" maxPercentage="25" />
    4.12 +	</categories>
    4.13 +	<sysStatsList defaultStats="defaultStats">
    4.14 +		<sysStats id="defaultStats">
    4.15 +			<sysStat name="M"/>
    4.16 +			<sysStat name="WS"/>
    4.17 +			<sysStat name="BS"/>
    4.18 +			<sysStat name="S"/>
    4.19 +			<sysStat name="T"/>
    4.20 +			<sysStat name="W"/>
    4.21 +			<sysStat name="I"/>
    4.22 +			<sysStat name="A"/>
    4.23 +			<sysStat name="Ld"/>
    4.24 +		</sysStats>
    4.25 +	</sysStatsList>
    4.26 +</system>