Mercurial > repos > IBBoard.WarFoundry.API.Tests
view API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 33:03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
* Add tests for race factory
* Add test data that references non-existstent system
* Make game system names for existing test data more distinct
Re #228: Crash with missing abilityID
* Initial failing test
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 24 Dec 2009 14:53:18 +0000 |
parents | |
children | 4302e6b2c5c1 |
line wrap: on
line source
// This file (WarFoundryXmlRaceFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard // // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; using System.Collections.Generic; using System.IO; using System.Xml; using NUnit.Framework; using IBBoard.WarFoundry.API.Objects; using IBBoard.IO; namespace IBBoard.WarFoundry.API.Factories.Xml { [TestFixture()] public class WarFoundryXmlRaceFactoryTest { [Test()] [ExpectedException(typeof(FileLoadException))] public void TestCompleteLoadingOnRaceWithMissingAbilityIdErrors () { ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/race-with-non-existant-ability.race")); Assert.AreEqual(1, objs.Count); IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); enumerator.Reset(); enumerator.MoveNext(); Race race = (Race)enumerator.Current; Category[] cats = race.Categories; } [Test()] [ExpectedException(typeof(InvalidFileException))] public void TestCompleteLoadingOnRaceWithMissingGameSystemErrors () { ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/race-with-non-existant-game-system.race")); Assert.AreEqual(1, objs.Count); IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); enumerator.Reset(); enumerator.MoveNext(); Race race = (Race)enumerator.Current; Category[] cats = race.Categories; } } }