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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
8d9d49332d44 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 9
diff changeset
1 // This file (WarFoundryLoaderTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2008, 2009 IBBoard.
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
11
8d9d49332d44 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 9
diff changeset
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
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.IO;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 namespace IBBoard.WarFoundry.API.Factories
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 [TestFixture()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 public class WarFoundryLoaderTest
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
19 private AbstractNativeWarFoundryFactory sysFactory;
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 public void TestLoadWithoutFactoriesCompletesWithoutError()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 WarFoundryLoader.GetDefault().LoadFiles();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 public void TestLoadingSystemCompletesWithoutError()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 {
35
4302e6b2c5c1 Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
30 AbstractWarFoundryLoader loader = WarFoundryLoader.GetDefault();
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
31 DirectoryInfo dir = new DirectoryInfo("testdata");
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
32 loader.RegisterFactory(GetSystemFactory());
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 loader.AddLoadDirectory(dir);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 loader.LoadFiles();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 Assert.Greater(loader.GetGameSystems().Length, 0);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 loader.RemoveLoadDirectory(dir);
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
37 loader.UnregisterFactory(GetSystemFactory());
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
49 private AbstractNativeWarFoundryFactory GetSystemFactory()
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 {
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
51 if (sysFactory == null)
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 {
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
53 sysFactory = new MockSystemFactory();
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
56 return sysFactory;
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 }