Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 66:f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
* Move some test data files to sub-folder
* Test duplicate ID validation failures for equipment slots and equipment IDs
* Test valid equipment references
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jul 2010 14:28:13 +0000 |
parents | fa536aee66d7 |
children | d3191c44f163 |
files | API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/invalid-contained-unit-reference.racex testdata/single-unit-with-invalid-equipment-reference.racex testdata/valid-contained-unit-reference.racex testdata/xml-race-factory/duplicate-equipment-id.racex testdata/xml-race-factory/invalid-contained-unit-reference.racex testdata/xml-race-factory/single-unit-with-duplicate-equipment-slot.racex testdata/xml-race-factory/single-unit-with-invalid-equipment-reference.racex testdata/xml-race-factory/single-unit-with-valid-equipment-reference.racex testdata/xml-race-factory/valid-contained-unit-reference.racex |
diffstat | 11 files changed, 204 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sun Jul 04 13:53:45 2010 +0000 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sun Jul 04 14:28:13 2010 +0000 @@ -79,6 +79,12 @@ } [Test()] + public void TestCompleteLoadingOnRaceWithDuplicateEquipmentSlotErrors() + { + TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-duplicate-equipment-slot.racex"); + } + + [Test()] public void TestCompleteLoadingOnRaceWithCorrectEquipmentSlotLoads() { SetDefaultGameSystem(); @@ -98,20 +104,36 @@ [Test()] public void TestCompleteLoadingOnRaceWithIncorrectEquipmentIDError() { - TestFileValidationFailure("testdata/single-unit-with-invalid-equipment-reference.racex"); + TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-invalid-equipment-reference.racex"); + } + + [Test()] + public void TestCompleteLoadingOnRaceWithDuplicateEquipmentIDError() + { + TestFileValidationFailure("testdata/xml-race-factory/duplicate-equipment-id.racex"); + } + + [Test()] + public void TestCompleteLoadingOnRaceWithCorrectEquipmentIDLoads() + { + SetDefaultGameSystem(); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/single-unit-with-valid-equipment-reference.racex"); + Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + UnitType unitType = race.GetUnitType("Empire1"); + Assert.That(unitType.GetEquipmentItem("Empire1equip1"), Is.Not.Null); } [Test()] public void TestCompleteLoadingOnRaceWithIncorrectContainedUnitIDError() { - TestFileValidationFailure("testdata/invalid-contained-unit-reference.racex"); + TestFileValidationFailure("testdata/xml-race-factory/invalid-contained-unit-reference.racex"); } [Test()] public void TestCompleteLoadingOnRaceWithCorrectContainedUnitIDLoadsData() { SetDefaultGameSystem(); - FileInfo raceFile = new FileInfo("testdata/valid-contained-unit-reference.racex"); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/valid-contained-unit-reference.racex"); Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); UnitType unitType = race.GetUnitType("Empire1"); Assert.That(unitType.ContainedUnitTypes, Has.Length(1));
--- a/IBBoard.WarFoundry.API.Tests.csproj Sun Jul 04 13:53:45 2010 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sun Jul 04 14:28:13 2010 +0000 @@ -103,9 +103,6 @@ <None Include="testdata\single-unit-multi-type-referencing-race-with-override.racex"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> - <None Include="testdata\single-unit-with-invalid-equipment-reference.racex"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> <None Include="testdata\single-unit-no-category.racex"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> @@ -143,12 +140,6 @@ <None Include="WarFoundryTests.nunit"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> - <None Include="testdata\invalid-contained-unit-reference.racex"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> - <None Include="testdata\valid-contained-unit-reference.racex"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> <None Include="testdata\xml-race-factory\different-extra-data-key.racex"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> @@ -182,6 +173,24 @@ <None Include="testdata\xml-race-factory\single-unit-with-no-equipment-slot-limit.racex"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="testdata\xml-race-factory\single-unit-with-invalid-equipment-reference.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\single-unit-with-valid-equipment-reference.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\valid-contained-unit-reference.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\invalid-contained-unit-reference.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\single-unit-with-duplicate-equipment-slot.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\duplicate-equipment-id.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
--- a/testdata/invalid-contained-unit-reference.racex Sun Jul 04 13:53:45 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default"> - <units> - <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> - <stats> - <stat name="M">4</stat> - <stat name="WS">6</stat> - <stat name="BS">6</stat> - <stat name="S">4</stat> - <stat name="T">4</stat> - <stat name="W">3</stat> - <stat name="I">6</stat> - <stat name="A">4</stat> - <stat name="Ld">9</stat> - </stats> - <contains> - <containedUnit containedID="Empire2" /> - </contains> - </unit> - </units> -</race> \ No newline at end of file
--- a/testdata/single-unit-with-invalid-equipment-reference.racex Sun Jul 04 13:53:45 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant"> - <units> - <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> - <stats> - <stat name="M">4</stat> - <stat name="WS">6</stat> - <stat name="BS">6</stat> - <stat name="S">4</stat> - <stat name="T">4</stat> - <stat name="W">3</stat> - <stat name="I">6</stat> - <stat name="A">4</stat> - <stat name="Ld">9</stat> - </stats> - <unitEquipment> - <unitEquipmentItem id="equip2"/> - </unitEquipment> - </unit> - </units> - <equipment> - <equipmentItem id="equip1" name="sword" cost="1"/> - </equipment> -</race> \ No newline at end of file
--- a/testdata/valid-contained-unit-reference.racex Sun Jul 04 13:53:45 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default"> - <units> - <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> - <stats> - <stat name="M">4</stat> - <stat name="WS">6</stat> - <stat name="BS">6</stat> - <stat name="S">4</stat> - <stat name="T">4</stat> - <stat name="W">3</stat> - <stat name="I">6</stat> - <stat name="A">4</stat> - <stat name="Ld">9</stat> - </stats> - <contains> - <containedUnit containedID="Empire2" /> - </contains> - </unit> - <unit id="Empire2" typeName="Minion" cat="cat1" points="0"> - <stats> - <stat name="M">4</stat> - <stat name="WS">2</stat> - <stat name="BS">2</stat> - <stat name="S">2</stat> - <stat name="T">2</stat> - <stat name="W">1</stat> - <stat name="I">2</stat> - <stat name="A">1</stat> - <stat name="Ld">5</stat> - </stats> - </unit> - </units> -</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/duplicate-equipment-id.racex Sun Jul 04 14:28:13 2010 +0000 @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <stats> + <stat name="M">4</stat> + <stat name="WS">6</stat> + <stat name="BS">6</stat> + <stat name="S">4</stat> + <stat name="T">4</stat> + <stat name="W">3</stat> + <stat name="I">6</stat> + <stat name="A">4</stat> + <stat name="Ld">9</stat> + </stats> + </unit> + </units> + <equipment> + <equipmentItem id="equip1" name="sword" cost="1"/> + <equipmentItem id="equip1" name="other item" cost="1"/> + </equipment> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/invalid-contained-unit-reference.racex Sun Jul 04 14:28:13 2010 +0000 @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <stats> + <stat name="M">4</stat> + <stat name="WS">6</stat> + <stat name="BS">6</stat> + <stat name="S">4</stat> + <stat name="T">4</stat> + <stat name="W">3</stat> + <stat name="I">6</stat> + <stat name="A">4</stat> + <stat name="Ld">9</stat> + </stats> + <contains> + <containedUnit containedID="Empire2" /> + </contains> + </unit> + </units> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/single-unit-with-duplicate-equipment-slot.racex Sun Jul 04 14:28:13 2010 +0000 @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <stats> + <stat name="M">4</stat> + <stat name="WS">6</stat> + <stat name="BS">6</stat> + <stat name="S">4</stat> + <stat name="T">4</stat> + <stat name="W">3</stat> + <stat name="I">6</stat> + <stat name="A">4</stat> + <stat name="Ld">9</stat> + </stats> + <equipmentSlots> + <equipmentSlot name="slot1"> + <maxLimit> + <core:absoluteLimit limit="1" /> + </maxLimit> + </equipmentSlot> + <equipmentSlot name="slot1"> + <maxLimit> + <core:absoluteLimit limit="1" /> + </maxLimit> + </equipmentSlot> + </equipmentSlots> + <unitEquipment> + <unitEquipmentItem id="equip1" equipmentSlot="slot1"/> + </unitEquipment> + </unit> + </units> + <equipment> + <equipmentItem id="equip1" name="sword" cost="1"/> + </equipment> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/single-unit-with-invalid-equipment-reference.racex Sun Jul 04 14:28:13 2010 +0000 @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <stats> + <stat name="M">4</stat> + <stat name="WS">6</stat> + <stat name="BS">6</stat> + <stat name="S">4</stat> + <stat name="T">4</stat> + <stat name="W">3</stat> + <stat name="I">6</stat> + <stat name="A">4</stat> + <stat name="Ld">9</stat> + </stats> + <unitEquipment> + <unitEquipmentItem id="equip2"/> + </unitEquipment> + </unit> + </units> + <equipment> + <equipmentItem id="equip1" name="sword" cost="1"/> + </equipment> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/single-unit-with-valid-equipment-reference.racex Sun Jul 04 14:28:13 2010 +0000 @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <stats> + <stat name="M">4</stat> + <stat name="WS">6</stat> + <stat name="BS">6</stat> + <stat name="S">4</stat> + <stat name="T">4</stat> + <stat name="W">3</stat> + <stat name="I">6</stat> + <stat name="A">4</stat> + <stat name="Ld">9</stat> + </stats> + <unitEquipment> + <unitEquipmentItem id="equip1"/> + </unitEquipment> + </unit> + </units> + <equipment> + <equipmentItem id="equip1" name="sword" cost="1"/> + </equipment> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/valid-contained-unit-reference.racex Sun Jul 04 14:28:13 2010 +0000 @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="default"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <stats> + <stat name="M">4</stat> + <stat name="WS">6</stat> + <stat name="BS">6</stat> + <stat name="S">4</stat> + <stat name="T">4</stat> + <stat name="W">3</stat> + <stat name="I">6</stat> + <stat name="A">4</stat> + <stat name="Ld">9</stat> + </stats> + <contains> + <containedUnit containedID="Empire2" /> + </contains> + </unit> + <unit id="Empire2" typeName="Minion" cat="cat1" points="0"> + <stats> + <stat name="M">4</stat> + <stat name="WS">2</stat> + <stat name="BS">2</stat> + <stat name="S">2</stat> + <stat name="T">2</stat> + <stat name="W">1</stat> + <stat name="I">2</stat> + <stat name="A">1</stat> + <stat name="Ld">5</stat> + </stats> + </unit> + </units> +</race> \ No newline at end of file