Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
annotate API/WarFoundryLoaderTest.cs @ 129:95dac00e9330
Re #27: Unit requirements
* Test getting all unit requirements for race
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 09 Apr 2011 19:13:42 +0000 |
parents | d1ec7618f812 |
children | 17c5030485dc |
rev | line source |
---|---|
11 | 1 // This file (WarFoundryLoaderTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2008, 2009 IBBoard. |
0 | 2 // |
11 | 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. |
0 | 4 |
5 using System; | |
6 using System.IO; | |
7 using NUnit.Framework; | |
12
a4e7e938d065
Re #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents:
11
diff
changeset
|
8 using IBBoard.WarFoundry.API.Factories.Mock; |
0 | 9 using IBBoard.WarFoundry.API.Objects; |
86
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
10 using NUnit.Framework.SyntaxHelpers; |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
11 using System.Collections.Generic; |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
12 using IBBoard.WarFoundry.API.Factories.Xml; |
0 | 13 |
14 namespace IBBoard.WarFoundry.API.Factories | |
15 { | |
16 [TestFixture()] | |
17 public class WarFoundryLoaderTest | |
18 { | |
9 | 19 private AbstractNativeWarFoundryFactory sysFactory; |
0 | 20 |
21 [Test()] | |
22 public void TestLoadWithoutFactoriesCompletesWithoutError() | |
23 { | |
24 WarFoundryLoader.GetDefault().LoadFiles(); | |
25 } | |
26 | |
27 [Test()] | |
28 public void TestLoadingSystemCompletesWithoutError() | |
29 { | |
35
4302e6b2c5c1
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
12
diff
changeset
|
30 AbstractWarFoundryLoader loader = WarFoundryLoader.GetDefault(); |
9 | 31 DirectoryInfo dir = new DirectoryInfo("testdata"); |
32 loader.RegisterFactory(GetSystemFactory()); | |
0 | 33 loader.AddLoadDirectory(dir); |
34 loader.LoadFiles(); | |
35 Assert.Greater(loader.GetGameSystems().Length, 0); | |
36 loader.RemoveLoadDirectory(dir); | |
9 | 37 loader.UnregisterFactory(GetSystemFactory()); |
0 | 38 } |
86
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
39 |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
40 [Test()] |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
41 public void TestBug318LoadingSingleFileShouldNotNullRef() |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
42 { |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
43 DefaultWarFoundryLoader loader = new DefaultWarFoundryLoader(); |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
44 loader.RegisterFactory(WarFoundryXmlFactory.GetFactory()); |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
45 ICollection<IWarFoundryObject> objs = loader.LoadFile(new FileInfo("testdata/Test.system")); |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
46 Assert.That(objs, Has.Count(1)); |
d1ec7618f812
Fixes #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
35
diff
changeset
|
47 } |
0 | 48 |
9 | 49 private AbstractNativeWarFoundryFactory GetSystemFactory() |
0 | 50 { |
9 | 51 if (sysFactory == null) |
0 | 52 { |
9 | 53 sysFactory = new MockSystemFactory(); |
0 | 54 } |
55 | |
9 | 56 return sysFactory; |
0 | 57 } |
58 } | |
59 } |