Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 68:a82f164e26e3
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
* Add test for invalid default stats ID
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jul 2010 19:11:08 +0000 |
parents | d3191c44f163 |
children | b2517bb113d0 |
files | API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/xml-system-factory/invalid-default-stats.systemx |
diffstat | 3 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs Sun Jul 04 15:05:00 2010 +0000 +++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs Sun Jul 04 19:11:08 2010 +0000 @@ -6,6 +6,8 @@ using System.IO; using IBBoard.WarFoundry.API.Objects; using NUnit.Framework.SyntaxHelpers; +using IBBoard.IO; +using System.Xml.Schema; namespace IBBoard.WarFoundry.API.Factories.Xml { @@ -36,6 +38,29 @@ Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); Assert.That(system.SystemStats, Has.Length(2)); } + + [Test()] + public void TestIncorrectDefaultStatsIDErrors() + { + TestFileValidationFailure("testdata/xml-system-factory/invalid-default-stats.systemx"); + } + + private void TestFileValidationFailure(string filePath) + { + FileInfo systemFile = new FileInfo(filePath); + + try + { + SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), systemFile); + Assert.Fail("Excepted exception not thrown"); + } + catch (InvalidFileException ex) + { + Console.WriteLine(ex.Message); + Exception innerException = ex.InnerException; + Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); + } + } } }
--- a/IBBoard.WarFoundry.API.Tests.csproj Sun Jul 04 15:05:00 2010 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sun Jul 04 19:11:08 2010 +0000 @@ -198,6 +198,9 @@ <None Include="testdata\xml-system-factory\valid-default-stats-multiple-stats-set.systemx"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="testdata\xml-system-factory\invalid-default-stats.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/invalid-default-stats.systemx Sun Jul 04 19:11:08 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="otherStats"> + <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>