Mercurial > repos > IBBoard.WarFoundry.API.Tests
diff API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 225:c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
* Add missing class
* Add tests for loading files and test data
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 14 Apr 2012 19:57:32 +0100 |
parents | ea104de9189e |
children | 7c21ca1482cb |
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sat Apr 14 16:58:20 2012 +0100 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Sat Apr 14 19:57:32 2012 +0100 @@ -384,6 +384,30 @@ Assert.That(unitType.GetRequirements()[0], Is.InstanceOfType(typeof(UnitRequiresNoMoreThanNOfUnitTypeRequirement))); } + [Test] + public void TestContainedUnitsAreLoaded() + { + SetDefaultGameSystem(); + Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/with-contained-only-unit.racex")); + Assert.That(race.GetUnitType("Empire2"), Is.Not.Null); + UnitType unitType1 = race.GetUnitType("Empire1"); + Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Length(1)); + Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType1)); + } + + [Test] + public void TestMixedContainedUnitsAreLoaded() + { + SetDefaultGameSystem(); + Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/with-mixed-contained-units.racex")); + Assert.That(race.GetUnitType("Empire2"), Is.Not.Null); + UnitType unitType1 = race.GetUnitType("Empire1"); + UnitType unitType3 = race.GetUnitType("Empire3"); + Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Length(2)); + Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType1)); + Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType3)); + } + private void TestFileValidationFailure(string filePath) { SetDefaultGameSystem();