annotate API/WarFoundryLoaderTest.cs @ 12:a4e7e938d065

Re #195: Setting max equipment without min may not function correctly * Initial commit of tests for limits (percentage and numeric) Also: * Reshuffle and refactoring of existing tests * Additional mocks required by the new tests
author IBBoard <dev@ibboard.co.uk>
date Mon, 12 Oct 2009 19:42:30 +0000
parents WarFoundryLoaderTest.cs@8d9d49332d44
children 4302e6b2c5c1
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;
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 namespace IBBoard.WarFoundry.API.Factories
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 [TestFixture()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public class WarFoundryLoaderTest
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
16 private AbstractNativeWarFoundryFactory sysFactory;
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 public void TestLoadWithoutFactoriesCompletesWithoutError()
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 WarFoundryLoader.GetDefault().LoadFiles();
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
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 [Test()]
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 public void TestLoadingSystemCompletesWithoutError()
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
27 WarFoundryLoader loader = WarFoundryLoader.GetDefault();
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
28 DirectoryInfo dir = new DirectoryInfo("testdata");
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
29 loader.RegisterFactory(GetSystemFactory());
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 loader.AddLoadDirectory(dir);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 loader.LoadFiles();
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 Assert.Greater(loader.GetGameSystems().Length, 0);
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 loader.RemoveLoadDirectory(dir);
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
34 loader.UnregisterFactory(GetSystemFactory());
0
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
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
37 private AbstractNativeWarFoundryFactory GetSystemFactory()
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 {
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
39 if (sysFactory == null)
0
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 {
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
41 sysFactory = new MockSystemFactory();
0
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
9
f96169484ba5 Fixes #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 4
diff changeset
44 return sysFactory;
0
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 }
faf976fe57df Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }