# HG changeset patch # User IBBoard # Date 1276962635 0 # Node ID f2348c00e6334eb24c7e75bcd3cbc1d3f0f3126c # Parent 6efa080b500f1a1c4b185f3f80ccfc5ca234f714 Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Add tests and test data for extra data keys diff -r 6efa080b500f -r f2348c00e633 API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs --- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Mon Jun 14 19:57:53 2010 +0000 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sat Jun 19 15:50:35 2010 +0000 @@ -129,6 +129,35 @@ UnitType unitType = race.GetUnitType("Empire1"); Assert.That(unitType.ContainedUnitTypes, Has.Length(1)); } + + [Test()] + public void TestCompleteLoadingOnRaceWithDuplicateExtraDataKeyErrors() + { + SetDefaultGameSystem(); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/duplicate-extra-data-key.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 TestCompleteLoadingOnRaceWithDifferentExtraDataKeysLoadsData() + { + SetDefaultGameSystem(); + FileInfo raceFile = new FileInfo("testdata/xml-race-factory/different-extra-data-key.racex"); + Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + UnitType unitType = race.GetUnitType("Empire1"); + Assert.That(unitType.GetExtraData("data1"), Is.EqualTo("")); + } [Test()] [ExpectedException(typeof(InvalidFileException), ExpectedMessage="Referenced game system, 'nonexistant-system', did not exist")] diff -r 6efa080b500f -r f2348c00e633 IBBoard.WarFoundry.API.Tests.csproj --- a/IBBoard.WarFoundry.API.Tests.csproj Mon Jun 14 19:57:53 2010 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sat Jun 19 15:50:35 2010 +0000 @@ -158,6 +158,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + @@ -187,4 +193,7 @@ + + + \ No newline at end of file diff -r 6efa080b500f -r f2348c00e633 testdata/xml-race-factory/different-extra-data-key.racex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/different-extra-data-key.racex Sat Jun 19 15:50:35 2010 +0000 @@ -0,0 +1,22 @@ + + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + + + + + \ No newline at end of file diff -r 6efa080b500f -r f2348c00e633 testdata/xml-race-factory/duplicate-extra-data-key.racex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/duplicate-extra-data-key.racex Sat Jun 19 15:50:35 2010 +0000 @@ -0,0 +1,22 @@ + + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + + + + + \ No newline at end of file