Mercurial > repos > IBBoard.WarFoundry.API.Tests
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 wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs Sun Jul 04 15:05:00 2010 +0000 @@ -0,0 +1,41 @@ +// This file (WarFoundryXmlSystemFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2010 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 NUnit.Framework; +using System.IO; +using IBBoard.WarFoundry.API.Objects; +using NUnit.Framework.SyntaxHelpers; + +namespace IBBoard.WarFoundry.API.Factories.Xml +{ + [TestFixture()] + public class WarFoundryXmlSystemFactoryTest + { + [Test()] + public void TestGettingDefaultStatsIDFullyLoadsGameSystem() + { + GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); + Assert.That(system.IsFullyLoaded, Is.False); + string temp = system.StandardSystemStatsID; + Assert.That(system.IsFullyLoaded, Is.True); + } + + [Test()] + public void TestValidDefaultStatsIDLoadsCorrectly() + { + GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); + Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); + Assert.That(system.SystemStats, Has.Length(1)); + } + + [Test()] + public void TestValidDefaultStatsIDLoadsCorrectlyWithMultipleStatsSets() + { + GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx")); + Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); + Assert.That(system.SystemStats, Has.Length(2)); + } + } +} +
--- a/IBBoard.WarFoundry.API.Tests.csproj Sun Jul 04 14:28:13 2010 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sun Jul 04 15:05:00 2010 +0000 @@ -64,6 +64,7 @@ <Compile Include="API\Factories\Xml\WarFoundryXmlArmyParserTest.cs" /> <Compile Include="API\FixedObjectWarFoundryLoader.cs" /> <Compile Include="API\Factories\Xml\WarFoundryXmlLimitParserTest.cs" /> + <Compile Include="API\Factories\Xml\WarFoundryXmlSystemFactoryTest.cs" /> </ItemGroup> <ItemGroup> <None Include="testdata\Test.race"> @@ -191,6 +192,12 @@ <None Include="testdata\xml-race-factory\duplicate-equipment-id.racex"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="testdata\xml-system-factory\valid-default-stats-one-stats-set.systemx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-system-factory\valid-default-stats-multiple-stats-set.systemx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73"> @@ -224,5 +231,6 @@ <Folder Include="testdata\xml-race-factory\" /> <Folder Include="testdata\" /> <Folder Include="testdata\" /> + <Folder Include="testdata\xml-system-factory\" /> </ItemGroup> </Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx Sun Jul 04 15:05:00 2010 +0000 @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<system xmlns="http://ibboard.co.uk/warfoundry/system" xmlns:cats="http://ibboard.co.uk/warfoundry/cats" id="default" name="Default Game System" warn="false"> + <categories> + <cats:cat id="cat1" name="Characters" minPercentage="0" maxPercentage="50" /> + <cats:cat id="cat2" name="Regiments" minPercentage="25" maxPercentage="100" /> + <cats:cat id="cat3" name="War Machines" minPercentage="0" maxPercentage="25" /> + <cats:cat id="cat4" name="Monsters" minPercentage="0" maxPercentage="25" /> + <cats:cat id="cat5" name="Allies" minPercentage="0" maxPercentage="25" /> + </categories> + <sysStatsList defaultStats="defaultStats"> + <sysStats id="defaultStats"> + <sysStat name="M"/> + <sysStat name="WS"/> + <sysStat name="BS"/> + <sysStat name="S"/> + <sysStat name="T"/> + <sysStat name="W"/> + <sysStat name="I"/> + <sysStat name="A"/> + <sysStat name="Ld"/> + </sysStats> + <sysStats id="otherStats"> + <sysStat name="M"/> + </sysStats> + </sysStatsList> +</system>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx Sun Jul 04 15:05:00 2010 +0000 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<system xmlns="http://ibboard.co.uk/warfoundry/system" xmlns:cats="http://ibboard.co.uk/warfoundry/cats" id="default" name="Default Game System" warn="false"> + <categories> + <cats:cat id="cat1" name="Characters" minPercentage="0" maxPercentage="50" /> + <cats:cat id="cat2" name="Regiments" minPercentage="25" maxPercentage="100" /> + <cats:cat id="cat3" name="War Machines" minPercentage="0" maxPercentage="25" /> + <cats:cat id="cat4" name="Monsters" minPercentage="0" maxPercentage="25" /> + <cats:cat id="cat5" name="Allies" minPercentage="0" maxPercentage="25" /> + </categories> + <sysStatsList defaultStats="defaultStats"> + <sysStats id="defaultStats"> + <sysStat name="M"/> + <sysStat name="WS"/> + <sysStat name="BS"/> + <sysStat name="S"/> + <sysStat name="T"/> + <sysStat name="W"/> + <sysStat name="I"/> + <sysStat name="A"/> + <sysStat name="Ld"/> + </sysStats> + </sysStatsList> +</system>