changeset 239:370bec16a364 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 diff
     1.1 --- a/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sun Apr 28 19:32:38 2013 +0100
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs	Sun Oct 16 20:29:35 2016 +0100
     1.3 @@ -408,6 +408,16 @@
     1.4  			Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType3));
     1.5  		}
     1.6  
     1.7 +		[Test]
     1.8 +		public void TestEquipmentTypeLoading()
     1.9 +		{
    1.10 +			SetDefaultGameSystem();
    1.11 +			Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/equipment-groups/equipment-with-type.racex"));
    1.12 +			UnitType unitType = race.GetUnitType("Empire1");
    1.13 +			Assert.That(unitType, Is.Not.Null);
    1.14 +			//TODO: Finish testing
    1.15 +		}
    1.16 +
    1.17  		private void TestFileValidationFailure(string filePath)
    1.18  		{
    1.19  			SetDefaultGameSystem();
     2.1 --- a/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sun Apr 28 19:32:38 2013 +0100
     2.2 +++ b/API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs	Sun Oct 16 20:29:35 2016 +0100
     2.3 @@ -95,6 +95,13 @@
     2.4  			Assert.That(system.SystemPtsNameSingle, Is.EqualTo("point"));
     2.5  		}
     2.6  
     2.7 +		[Test]
     2.8 +		public void TestLoadingEquipmentCategories()
     2.9 +		{
    2.10 +			GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/default.systemx"));
    2.11 +			Assert.That(system.EquipmentCategories, Is.EquivalentTo(new EquipmentCategory[]{new EquipmentCategory("equip1", "Weapons"), new EquipmentCategory("equip2", "Armour")}));
    2.12 +		}
    2.13 +
    2.14  		private void TestFileValidationFailure(string filePath)
    2.15  		{
    2.16  			FileInfo systemFile = new FileInfo(filePath);
     3.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sun Apr 28 19:32:38 2013 +0100
     3.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Oct 16 20:29:35 2016 +0100
     3.3 @@ -336,6 +336,9 @@
     3.4      <None Include="testdata\xml-race-factory\with-mixed-contained-units.racex">
     3.5        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     3.6      </None>
     3.7 +    <None Include="testdata\equipment-groups\equipment-with-type.racex">
     3.8 +      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     3.9 +    </None>
    3.10    </ItemGroup>
    3.11    <ItemGroup>
    3.12      <Reference Include="System" />
    3.13 @@ -410,6 +413,7 @@
    3.14    <ItemGroup>
    3.15      <Folder Include="API\Savers\Xml\" />
    3.16      <Folder Include="API\Loading\" />
    3.17 +    <Folder Include="testdata\equipment-groups\" />
    3.18    </ItemGroup>
    3.19    <ItemGroup>
    3.20      <Content Include="testdata\xml_output.xml">
     4.1 --- a/testdata/default.systemx	Sun Apr 28 19:32:38 2013 +0100
     4.2 +++ b/testdata/default.systemx	Sun Oct 16 20:29:35 2016 +0100
     4.3 @@ -20,4 +20,8 @@
     4.4  			<sysStat name="Ld"/>
     4.5  		</sysStats>
     4.6  	</sysStatsList>
     4.7 +	<equipmentTypes>
     4.8 +		<equipmentType id="weapon" name="Weapons" />
     4.9 +		<equipmentType id="armour" name="Armour" />
    4.10 +	</equipmentTypes>
    4.11  </system>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/testdata/equipment-groups/equipment-with-type.racex	Sun Oct 16 20:29:35 2016 +0100
     5.3 @@ -0,0 +1,26 @@
     5.4 +<?xml version="1.0" encoding="UTF-8"?>
     5.5 +<race xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:core="http://ibboard.co.uk/warfoundry/core" id="Empire" name="Empire" system="nonexistant">
     5.6 +	<units>
     5.7 +		<unit id="Empire1" typeName="Empire General" cat="cat1" points="100" maxNum="1" maxSize="1">
     5.8 +			<stats>
     5.9 +				<stat name="M">4</stat>
    5.10 +				<stat name="WS">6</stat>
    5.11 +				<stat name="BS">6</stat>
    5.12 +				<stat name="S">4</stat>
    5.13 +				<stat name="T">4</stat>
    5.14 +				<stat name="W">3</stat>
    5.15 +				<stat name="I">6</stat>
    5.16 +				<stat name="A">4</stat>
    5.17 +				<stat name="Ld">9</stat>
    5.18 +			</stats>
    5.19 +			<unitEquipment>
    5.20 +				<unitEquipmentItem id="equip1"/>
    5.21 +				<unitEquipmentItem id="equip2"/>
    5.22 +			</unitEquipment>
    5.23 +		</unit>
    5.24 +	</units>
    5.25 +	<equipment>
    5.26 +		<equipmentItem id="equip1" name="sword" cost="1" type="weapon" />
    5.27 +		<equipmentItem id="equip2" name="shield" cost="1" type="armour" />
    5.28 +	</equipment>
    5.29 +</race>
    5.30 \ No newline at end of file