Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
comparison 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 |
comparison
equal
deleted
inserted
replaced
32:9bf542b76de2 | 33:03a8ab5e90d6 |
---|---|
1 // This file (WarFoundryXmlRaceFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard | |
2 // | |
3 // 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. | |
4 | |
5 using System; | |
6 using System.Collections.Generic; | |
7 using System.IO; | |
8 using System.Xml; | |
9 using NUnit.Framework; | |
10 using IBBoard.WarFoundry.API.Objects; | |
11 using IBBoard.IO; | |
12 | |
13 namespace IBBoard.WarFoundry.API.Factories.Xml | |
14 { | |
15 | |
16 | |
17 [TestFixture()] | |
18 public class WarFoundryXmlRaceFactoryTest | |
19 { | |
20 [Test()] | |
21 [ExpectedException(typeof(FileLoadException))] | |
22 public void TestCompleteLoadingOnRaceWithMissingAbilityIdErrors () | |
23 { | |
24 ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/race-with-non-existant-ability.race")); | |
25 Assert.AreEqual(1, objs.Count); | |
26 IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); | |
27 enumerator.Reset(); | |
28 enumerator.MoveNext(); | |
29 Race race = (Race)enumerator.Current; | |
30 Category[] cats = race.Categories; | |
31 } | |
32 | |
33 [Test()] | |
34 [ExpectedException(typeof(InvalidFileException))] | |
35 public void TestCompleteLoadingOnRaceWithMissingGameSystemErrors () | |
36 { | |
37 ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/race-with-non-existant-game-system.race")); | |
38 Assert.AreEqual(1, objs.Count); | |
39 IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); | |
40 enumerator.Reset(); | |
41 enumerator.MoveNext(); | |
42 Race race = (Race)enumerator.Current; | |
43 Category[] cats = race.Categories; | |
44 } | |
45 } | |
46 } |