comparison WarFoundryLoaderTest.cs @ 0:faf976fe57df

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 40b31dfd6a46
comparison
equal deleted inserted replaced
-1:000000000000 0:faf976fe57df
1 // WarFoundryLoaderTest.cs
2 //
3 // Copyright (C) 2008 IBBoard
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 //
19 //
20
21 using System;
22 using System.IO;
23 using NUnit.Framework;
24 using IBBoard.WarFoundry.API.Objects;
25
26 namespace IBBoard.WarFoundry.API.Factories
27 {
28 [TestFixture()]
29 public class WarFoundryLoaderTest
30 {
31 private AbstractNativeWarFoundryFactory factory;
32
33 [Test()]
34 public void TestLoadWithoutFactoriesCompletesWithoutError()
35 {
36 WarFoundryLoader.GetDefault().LoadFiles();
37 }
38
39 [Test()]
40 public void TestLoadingSystemCompletesWithoutError()
41 {
42 WarFoundryLoader loader = GetSystemLoader();
43 DirectoryInfo dir = new DirectoryInfo("/");
44 loader.RegisterFactory(GetFactory());
45 loader.AddLoadDirectory(dir);
46 loader.LoadFiles();
47 Assert.Greater(loader.GetGameSystems().Length, 0);
48 loader.RemoveLoadDirectory(dir);
49 loader.UnregisterFactory(GetFactory());
50 }
51
52 private AbstractNativeWarFoundryFactory GetFactory()
53 {
54 if (factory == null)
55 {
56 factory = new MockFactory();
57 }
58
59 return factory;
60 }
61
62 private WarFoundryLoader GetSystemLoader()
63 {
64 return new FixedFileWarFoundryLoader(new MockSystemZipFile());
65 }
66
67 private WarFoundryLoader GetRaceLoader()
68 {
69 return new FixedFileWarFoundryLoader(new MockRaceZipFile());
70 }
71 }
72 }