# HG changeset patch # User IBBoard # Date 1327179662 0 # Node ID 2b27447ae74e9f5087414681b901f215a1542fd7 # Parent 49e50238c3809a9f982a2c1b0683af29ecea4e36 Re #352: Test/fix cyclic references in unit types * Add test case diff -r 49e50238c380 -r 2b27447ae74e API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs --- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Fri Dec 23 15:33:53 2011 +0000 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sat Jan 21 21:01:02 2012 +0000 @@ -375,6 +375,15 @@ Assert.That(unitType.GetRequirements()[0], Is.InstanceOfType(typeof(UnitRequiresAtLeastNUnitsRequirement))); } + [Test] + public void TestCyclicReferenceDoesNotCrash() + { + SetDefaultGameSystem(); + Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/cyclic.racex")); + UnitType unitType = race.GetUnitType("Empire1"); + Assert.That(unitType.GetRequirements()[0], Is.InstanceOfType(typeof(UnitRequiresAtLeastNUnitsRequirement))); + } + private void TestFileValidationFailure(string filePath) { SetDefaultGameSystem(); diff -r 49e50238c380 -r 2b27447ae74e IBBoard.WarFoundry.API.Tests.csproj --- a/IBBoard.WarFoundry.API.Tests.csproj Fri Dec 23 15:33:53 2011 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sat Jan 21 21:01:02 2012 +0000 @@ -314,6 +314,9 @@ PreserveNewest + + PreserveNewest + diff -r 49e50238c380 -r 2b27447ae74e testdata/xml-race-factory/cyclic.racex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testdata/xml-race-factory/cyclic.racex Sat Jan 21 21:01:02 2012 +0000 @@ -0,0 +1,50 @@ + + + + + + + + + + + + + 4 + 6 + 6 + 4 + 4 + 3 + 6 + 4 + 9 + + + + + Empire2:4 + + + + + + 4 + 2 + 2 + 2 + 2 + 1 + 2 + 1 + 5 + + + + + Empire1 + + + + + \ No newline at end of file