Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 71:a2095a3685fc
Re #297: Move Categories over to key/keyref from ID/IDREF
* Initial tests for system category handling
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 07 Jul 2010 19:01:32 +0000 |
parents | 90a9f13b9627 |
children | d1d79adcb11d |
files | API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/xml-system-factory/duplicate-category-ids.systemx testdata/xml-system-factory/valid-categories.systemx |
diffstat | 4 files changed, 61 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs Mon Jul 05 19:49:24 2010 +0000 +++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs Wed Jul 07 19:01:32 2010 +0000 @@ -53,6 +53,18 @@ TestFileValidationFailure("testdata/xml-system-factory/duplicate-stats-set-id.systemx"); } + [Test()] + public void TestValidCategoriesLoadsCorrectly() + { + GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-categories.systemx")); + Assert.That(system.Categories, Has.Length(5)); + } + + [Test()] + public void TestDuplicateCategoryIDErrors() + { + TestFileValidationFailure("testdata/xml-system-factory/duplicate-category-ids.systemx"); + } private void TestFileValidationFailure(string filePath) {
--- a/IBBoard.WarFoundry.API.Tests.csproj Mon Jul 05 19:49:24 2010 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Wed Jul 07 19:01:32 2010 +0000 @@ -213,6 +213,12 @@ <None Include="testdata\xml-system-factory\duplicate-stats-set-id.systemx"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="testdata\xml-system-factory\valid-categories.systemx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-system-factory\duplicate-category-ids.systemx"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-system-factory/duplicate-category-ids.systemx Wed Jul 07 19:01:32 2010 +0000 @@ -0,0 +1,20 @@ +<?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="cat1" name="Regiments" minPercentage="25" maxPercentage="100" /> + </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>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-system-factory/valid-categories.systemx Wed Jul 07 19:01:32 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>