changeset 239:370bec16a364 default tip

Add initial testing for equipment with type (incomplete)
author IBBoard <dev@ibboard.co.uk>
date Sun, 16 Oct 2016 20:29:35 +0100
parents e173c5512067
children
files API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs IBBoard.WarFoundry.API.Tests.csproj testdata/default.systemx testdata/equipment-groups/equipment-with-type.racex
diffstat 5 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sun Apr 28 19:32:38 2013 +0100
+++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sun Oct 16 20:29:35 2016 +0100
@@ -408,6 +408,16 @@
 			Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType3));
 		}
 
+		[Test]
+		public void TestEquipmentTypeLoading()
+		{
+			SetDefaultGameSystem();
+			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/equipment-groups/equipment-with-type.racex"));
+			UnitType unitType = race.GetUnitType("Empire1");
+			Assert.That(unitType, Is.Not.Null);
+			//TODO: Finish testing
+		}
+
 		private void TestFileValidationFailure(string filePath)
 		{
 			SetDefaultGameSystem();
--- a/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sun Apr 28 19:32:38 2013 +0100
+++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sun Oct 16 20:29:35 2016 +0100
@@ -95,6 +95,13 @@
 			Assert.That(system.SystemPtsNameSingle, Is.EqualTo("point"));
 		}
 
+		[Test]
+		public void TestLoadingEquipmentCategories()
+		{
+			GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/default.systemx"));
+			Assert.That(system.EquipmentCategories, Is.EquivalentTo(new EquipmentCategory[]{new EquipmentCategory("equip1", "Weapons"), new EquipmentCategory("equip2", "Armour")}));
+		}
+
 		private void TestFileValidationFailure(string filePath)
 		{
 			FileInfo systemFile = new FileInfo(filePath);
--- a/IBBoard.WarFoundry.API.Tests.csproj	Sun Apr 28 19:32:38 2013 +0100
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Oct 16 20:29:35 2016 +0100
@@ -336,6 +336,9 @@
     <None Include="testdata\xml-race-factory\with-mixed-contained-units.racex">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="testdata\equipment-groups\equipment-with-type.racex">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
@@ -410,6 +413,7 @@
   <ItemGroup>
     <Folder Include="API\Savers\Xml\" />
     <Folder Include="API\Loading\" />
+    <Folder Include="testdata\equipment-groups\" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="testdata\xml_output.xml">
--- a/testdata/default.systemx	Sun Apr 28 19:32:38 2013 +0100
+++ b/testdata/default.systemx	Sun Oct 16 20:29:35 2016 +0100
@@ -20,4 +20,8 @@
 			<sysStat name="Ld"/>
 		</sysStats>
 	</sysStatsList>
+	<equipmentTypes>
+		<equipmentType id="weapon" name="Weapons" />
+		<equipmentType id="armour" name="Armour" />
+	</equipmentTypes>
 </system>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testdata/equipment-groups/equipment-with-type.racex	Sun Oct 16 20:29:35 2016 +0100
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant">
+	<units>
+		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
+			<stats>
+				<stat name="M">4</stat>
+				<stat name="WS">6</stat>
+				<stat name="BS">6</stat>
+				<stat name="S">4</stat>
+				<stat name="T">4</stat>
+				<stat name="W">3</stat>
+				<stat name="I">6</stat>
+				<stat name="A">4</stat>
+				<stat name="Ld">9</stat>
+			</stats>
+			<unitEquipment>
+				<unitEquipmentItem id="equip1"/>
+				<unitEquipmentItem id="equip2"/>
+			</unitEquipment>
+		</unit>
+	</units>
+	<equipment>
+		<equipmentItem id="equip1" name="sword" cost="1" type="weapon" />
+		<equipmentItem id="equip2" name="shield" cost="1" type="armour" />
+	</equipment>
+</race>
\ No newline at end of file