comparison API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 63:a9163f8dfba1

Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type * Move invalid equipment slot data file to sub-folder * Add test for valid equipment slot (currently null-refs and fails)
author IBBoard <dev@ibboard.co.uk>
date Sat, 03 Jul 2010 19:54:42 +0000
parents ef8950a5f4cb
children 6f638d6f400f
comparison
equal deleted inserted replaced
62:ef8950a5f4cb 63:a9163f8dfba1
126 126
127 [Test()] 127 [Test()]
128 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors() 128 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors()
129 { 129 {
130 SetDefaultGameSystem(); 130 SetDefaultGameSystem();
131 FileInfo raceFile = new FileInfo("testdata/single-unit-with-invalid-equipment-slot-reference.racex"); 131 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/single-unit-with-invalid-equipment-slot-reference.racex");
132 132
133 try 133 try
134 { 134 {
135 SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); 135 SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
136 Assert.Fail("Excepted exception not thrown"); 136 Assert.Fail("Excepted exception not thrown");
137 } 137 }
138 catch (InvalidFileException ex) 138 catch (InvalidFileException ex)
139 { 139 {
140 Console.WriteLine(ex.Message); 140 Console.WriteLine(ex.Message);
141 Exception innerException = ex.InnerException; 141 Exception innerException = ex.InnerException;
142 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); 142 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException)));
143 } 143 }
144 }
145
146 [Test()]
147 public void TestCompleteLoadingOnRaceWithCorrectEquipmentSlotLoads()
148 {
149 SetDefaultGameSystem();
150 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/single-unit-with-valid-equipment-slot-reference.racex");
151 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile);
152 UnitType unitType = race.GetUnitType("General");
153 UnitEquipmentItem unitEquipmentItem = unitType.GetEquipmentItem("equip1");
154 Assert.That(unitEquipmentItem.SlotName, Is.EqualTo("slot1"));
144 } 155 }
145 156
146 [Test()] 157 [Test()]
147 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentIDError() 158 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentIDError()
148 { 159 {