annotate WarFoundryLoaderTest.cs @ 5:90f63edddc94

Re #30 - Migrate WarFoundry to .csproj * Migrate API tests to .csproj and remove .mdp Also remove old test results from source control
author IBBoard <dev@ibboard.co.uk>
date Tue, 17 Feb 2009 16:30:12 +0000
parents 4222cfa99c78
children f96169484ba5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
4222cfa99c78 Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
1 // This file (WarFoundryLoaderTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
4
4222cfa99c78 Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL 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;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Objects;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 namespace IBBoard.WarFoundry.API.Factories
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 [TestFixture()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 public class WarFoundryLoaderTest
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 private AbstractNativeWarFoundryFactory factory;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 public void TestLoadWithoutFactoriesCompletesWithoutError()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 WarFoundryLoader.GetDefault().LoadFiles();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 public void TestLoadingSystemCompletesWithoutError()
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 WarFoundryLoader loader = GetSystemLoader();
3
40b31dfd6a46 Update tests (one currently fails because of "end of stream" that doesn't occur when using factories normally)
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
27 DirectoryInfo dir = new DirectoryInfo(".");
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 loader.RegisterFactory(GetFactory());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 loader.AddLoadDirectory(dir);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 loader.LoadFiles();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 Assert.Greater(loader.GetGameSystems().Length, 0);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 loader.RemoveLoadDirectory(dir);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 loader.UnregisterFactory(GetFactory());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 private AbstractNativeWarFoundryFactory GetFactory()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 if (factory == null)
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 factory = new MockFactory();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 return factory;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 private WarFoundryLoader GetSystemLoader()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 return new FixedFileWarFoundryLoader(new MockSystemZipFile());
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 private WarFoundryLoader GetRaceLoader()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 return new FixedFileWarFoundryLoader(new MockRaceZipFile());
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 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 }