Mercurial > repos > IBBoard.WarFoundry.API.Tests
changeset 62:ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
* Test duplicate member type keys
* Test valid case of member type key with reference
* Move existing "non-existant member type" data to sub-folder and rename
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 19 Jun 2010 19:30:58 +0000 |
parents | 27625216d8d6 |
children | a9163f8dfba1 |
files | API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/single-unit-non-existant-type-referencing-race.racex testdata/xml-race-factory/duplicate-ability.racex testdata/xml-race-factory/duplicate-member-type.racex testdata/xml-race-factory/existing-member-type.racex testdata/xml-race-factory/non-existant-member-type.racex |
diffstat | 7 files changed, 181 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sat Jun 19 19:09:07 2010 +0000 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sat Jun 19 19:30:58 2010 +0000 @@ -45,6 +45,25 @@ } [Test()] + public void TestCompleteLoadingOnRaceWithDuplicateAbilityIdErrors() + { + SetDefaultGameSystem(); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/duplicate-ability.racex"); + + try + { + SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + Assert.Fail("Excepted exception not thrown"); + } + catch (InvalidFileException ex) + { + Console.WriteLine(ex.Message); + Exception innerException = ex.InnerException; + Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); + } + } + + [Test()] public void TestCompleteLoadingOnRaceWithAbilityLoadsData() { SetDefaultGameSystem(); @@ -54,15 +73,14 @@ Ability ability = race.GetAbility("leaderOfMen"); Assert.That(ability.Name, Is.EqualTo("Leader of Men")); Assert.That(ability.Description, Is.EqualTo("All men will follow the character and can use his leadership")); - Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability)); - + Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability)); } [Test()] - public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDError() + public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDErrors() { SetDefaultGameSystem(); - FileInfo raceFile = new FileInfo("testdata/single-unit-non-existant-type-referencing-race.racex"); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/non-existant-member-type.racex"); try { @@ -78,6 +96,35 @@ } [Test()] + public void TestCompleteLoadingOnRaceWithDuplicateMemberTypeIDErrors() + { + SetDefaultGameSystem(); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/duplicate-member-type.racex"); + + try + { + SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + Assert.Fail("Excepted exception not thrown"); + } + catch (InvalidFileException ex) + { + Console.WriteLine(ex.Message); + Exception innerException = ex.InnerException; + Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); + } + } + + [Test()] + public void TestCompleteLoadingOnRaceWithMemberTypeLoadsData() + { + SetDefaultGameSystem(); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-member-type.racex"); + Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + UnitMemberType memberType = race.GetUnitMemberType("General"); + Assert.That(memberType.Name, Is.EqualTo("General")); + } + + [Test()] public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors() { SetDefaultGameSystem();
--- a/IBBoard.WarFoundry.API.Tests.csproj Sat Jun 19 19:09:07 2010 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sat Jun 19 19:30:58 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-non-existant-type-referencing-race.racex"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> <None Include="testdata\single-unit-with-invalid-equipment-reference.racex"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> @@ -167,6 +164,18 @@ <None Include="testdata\xml-race-factory\existing-ability.racex"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="testdata\xml-race-factory\duplicate-ability.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\non-existant-member-type.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\duplicate-member-type.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="testdata\xml-race-factory\existing-member-type.racex"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73"> @@ -199,5 +208,6 @@ <ItemGroup> <Folder Include="testdata\xml-race-factory\" /> <Folder Include="testdata\" /> + <Folder Include="testdata\" /> </ItemGroup> </Project> \ No newline at end of file
--- a/testdata/single-unit-non-existant-type-referencing-race.racex Sat Jun 19 19:09:07 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +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="EmpireAlt" name="Empire (Extended)" system="default"> - <units> - <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> - <unitMembers> - <unitMember typeID="Empire1"/> - </unitMembers> - </unit> - </units> - <memberTypes> - <memberType id="General" name="General"> - <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> - </memberType> - </memberTypes> -</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/duplicate-ability.racex Sat Jun 19 19:30:58 2010 +0000 @@ -0,0 +1,29 @@ +<?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> + <unitAbilities> + <unitAbility abilityID="leaderOfMen"/> + </unitAbilities> + </unit> + </units> + <abilities> + <ability id="leaderOfMen" name="Leader of Men"> + <description>All men will follow the character and can use his leadership</description> + </ability> + <ability id="leaderOfMen" name="Leader of Other Men"> + <description>A duplicate!</description> + </ability> + </abilities> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/duplicate-member-type.racex Sat Jun 19 19:30:58 2010 +0000 @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="EmpireAlt" name="Empire (Extended)" system="default"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <unitMembers> + <unitMember typeID="General"/> + </unitMembers> + </unit> + </units> + <memberTypes> + <memberType id="General" name="General"> + <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> + </memberType> + <memberType id="General" name="Other General"> + <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> + </memberType> + </memberTypes> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/existing-member-type.racex Sat Jun 19 19:30:58 2010 +0000 @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="EmpireAlt" name="Empire (Extended)" system="default"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <unitMembers> + <unitMember typeID="General"/> + </unitMembers> + </unit> + </units> + <memberTypes> + <memberType id="General" name="General"> + <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> + </memberType> + </memberTypes> +</race> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/non-existant-member-type.racex Sat Jun 19 19:30:58 2010 +0000 @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="EmpireAlt" name="Empire (Extended)" system="default"> + <units> + <unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1"> + <unitMembers> + <unitMember typeID="Empire1"/> + </unitMembers> + </unit> + </units> + <memberTypes> + <memberType id="General" name="General"> + <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> + </memberType> + </memberTypes> +</race> \ No newline at end of file