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;
|
|
8 using IBBoard.WarFoundry.API.Objects;
|
9
|
9 using IBBoard.WarFoundry.API.Factories.Xml;
|
0
|
10
|
|
11 namespace IBBoard.WarFoundry.API.Factories
|
|
12 {
|
|
13 [TestFixture()]
|
|
14 public class WarFoundryLoaderTest
|
|
15 {
|
9
|
16 private AbstractNativeWarFoundryFactory sysFactory;
|
0
|
17
|
|
18 [Test()]
|
|
19 public void TestLoadWithoutFactoriesCompletesWithoutError()
|
|
20 {
|
|
21 WarFoundryLoader.GetDefault().LoadFiles();
|
|
22 }
|
|
23
|
|
24 [Test()]
|
|
25 public void TestLoadingSystemCompletesWithoutError()
|
|
26 {
|
9
|
27 WarFoundryLoader loader = WarFoundryLoader.GetDefault();
|
|
28 DirectoryInfo dir = new DirectoryInfo("testdata");
|
|
29 loader.RegisterFactory(GetSystemFactory());
|
0
|
30 loader.AddLoadDirectory(dir);
|
|
31 loader.LoadFiles();
|
|
32 Assert.Greater(loader.GetGameSystems().Length, 0);
|
|
33 loader.RemoveLoadDirectory(dir);
|
9
|
34 loader.UnregisterFactory(GetSystemFactory());
|
0
|
35 }
|
|
36
|
9
|
37 private AbstractNativeWarFoundryFactory GetSystemFactory()
|
0
|
38 {
|
9
|
39 if (sysFactory == null)
|
0
|
40 {
|
9
|
41 sysFactory = new MockSystemFactory();
|
0
|
42 }
|
|
43
|
9
|
44 return sysFactory;
|
0
|
45 }
|
|
46 }
|
|
47 }
|