Mercurial > repos > IBBoard.WarFoundry.API.Tests
diff API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 51:9d68b5dd70b3
Re #270: Add multiple categories to API
* Add test for unit being in multiple categories
Also:
* Add assertions in other tests that unit is cached in army
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 19 May 2010 19:22:20 +0000 |
parents | d3519f38a0f4 |
children | 745820ad7656 |
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Tue May 18 19:57:44 2010 +0000 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs Wed May 19 19:22:20 2010 +0000 @@ -71,6 +71,7 @@ SetDefaultGameSystem(); FileInfo raceFile = new FileInfo("testdata/single-unit-race.racex"); Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); Assert.AreEqual(1, unitTypes.Length); UnitType unitType = unitTypes[0]; @@ -87,6 +88,7 @@ SetDefaultGameSystem(); FileInfo raceFile = new FileInfo("testdata/single-unit-type-referencing-race.racex"); Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); Assert.AreEqual(1, unitTypes.Length); UnitType unitType = unitTypes[0]; @@ -103,6 +105,7 @@ SetDefaultGameSystem(); FileInfo raceFile = new FileInfo("testdata/single-unit-multi-type-referencing-race.racex"); Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); Assert.AreEqual(1, unitTypes.Length); UnitType unitType = unitTypes[0]; @@ -122,6 +125,7 @@ SetDefaultGameSystem(); FileInfo raceFile = new FileInfo("testdata/single-unit-multi-type-referencing-race-with-override.racex"); Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); Assert.AreEqual(1, unitTypes.Length); UnitType unitType = unitTypes[0]; @@ -140,6 +144,7 @@ SetDefaultGameSystem(); FileInfo raceFile = new FileInfo("testdata/single-unit-no-stats-race.racex"); Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); Assert.AreEqual(1, unitTypes.Length); UnitType unitType = unitTypes[0]; @@ -199,6 +204,25 @@ Assert.That(unitType.Categories, Has.Member(category)); Assert.That(unitType.Categories, Has.Member(race.GetCategory("cat2"))); } + + [Test()] + public void TestSingleUnitArmyWithMultipleCategoriesIsInEachCategory() + { + SetDefaultGameSystem(); + FileInfo raceFile = new FileInfo("testdata/single-unit-two-categories.racex"); + Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); + UnitType unitType = race.GetUnitType("Empire1"); + Assert.That(unitType.Categories.Length, Is.EqualTo(2)); + Category cat1 = race.GetCategory("cat1"); + Category cat2 = race.GetCategory("cat2"); + Assert.That(unitType.MainCategory, Is.EqualTo(cat1)); + Assert.That(unitType.Categories, Has.Member(cat1)); + Assert.That(unitType.Categories, Has.Member(cat2)); + Assert.That(race.GetUnitTypes(cat1), Is.All.EqualTo(unitType)); + UnitType[] unitTypesCat2 = race.GetUnitTypes(cat2); + Assert.That(unitTypesCat2, Has.Length(1)); + Assert.That(unitTypesCat2, Is.All.EqualTo(unitType)); + } private static void SetDefaultGameSystem() {