# HG changeset patch # User IBBoard # Date 1276975858 0 # Node ID ef8950a5f4cb80df05c5f8f5c2bc28b6189de16c # Parent 27625216d8d6d7d243e425f242e13340d1dfe3f3 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 diff -r 27625216d8d6 -r ef8950a5f4cb API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs --- 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(); diff -r 27625216d8d6 -r ef8950a5f4cb IBBoard.WarFoundry.API.Tests.csproj --- 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 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -167,6 +164,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + @@ -199,5 +208,6 @@ + \ No newline at end of file diff -r 27625216d8d6 -r ef8950a5f4cb testdata/single-unit-non-existant-type-referencing-race.racex --- 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 @@ - - - - - - - - - - - - - 4 - 6 - 6 - 4 - 4 - 3 - 6 - 4 - 9 - - - - \ No newline at end of file diff -r 27625216d8d6 -r ef8950a5f4cb testdata/xml-race-factory/duplicate-ability.racex --- /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 @@ + + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + + + + + + All men will follow the character and can use his leadership + + + A duplicate! + + + \ No newline at end of file diff -r 27625216d8d6 -r ef8950a5f4cb testdata/xml-race-factory/duplicate-member-type.racex --- /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 @@ + + + + + + + + + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + \ No newline at end of file diff -r 27625216d8d6 -r ef8950a5f4cb testdata/xml-race-factory/existing-member-type.racex --- /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 @@ + + + + + + + + + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + \ No newline at end of file diff -r 27625216d8d6 -r ef8950a5f4cb testdata/xml-race-factory/non-existant-member-type.racex --- /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 @@ + + + + + + + + + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + \ No newline at end of file