Mercurial > repos > IBBoard.WarFoundry.API.Tests
comparison API/Factories/Xml/WarFoundryXmlFactoryTests.cs @ 228:7c21ca1482cb
Re #419: Remove assumptions of a file-based install
* Update tests to use new "loadable object" and "loadable object source" wrappers
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 07 Jul 2012 21:02:53 +0100 |
parents | 3c2c108a2f08 |
children | 6ec46f3db2d4 |
comparison
equal
deleted
inserted
replaced
227:d8cd6b259a9f | 228:7c21ca1482cb |
---|---|
2 using NUnit.Framework; | 2 using NUnit.Framework; |
3 using System.IO; | 3 using System.IO; |
4 using System.Collections.Generic; | 4 using System.Collections.Generic; |
5 using IBBoard.WarFoundry.API.Objects; | 5 using IBBoard.WarFoundry.API.Objects; |
6 using NUnit.Framework.SyntaxHelpers; | 6 using NUnit.Framework.SyntaxHelpers; |
7 using IBBoard.WarFoundry.API.Loading; | |
7 | 8 |
8 namespace IBBoard.WarFoundry.API.Factories.Xml | 9 namespace IBBoard.WarFoundry.API.Factories.Xml |
9 { | 10 { |
10 [TestFixture()] | 11 [TestFixture()] |
11 public class WarFoundryXmlFactoryTests | 12 public class WarFoundryXmlFactoryTests |
17 WarFoundryLoader.SetDefault(loader); | 18 WarFoundryLoader.SetDefault(loader); |
18 WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); | 19 WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); |
19 try | 20 try |
20 { | 21 { |
21 loader.RegisterFactory(factory); | 22 loader.RegisterFactory(factory); |
22 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.system")); | 23 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new LoadableFileObject("testdata/multifile-zips/Test.system")); |
23 Assert.That(objs, Has.Count(2)); | 24 Assert.That(objs, Has.Count(2)); |
24 int raceCount = 0; | 25 int raceCount = 0; |
25 int systemCount = 0; | 26 int systemCount = 0; |
26 | 27 |
27 foreach (IWarFoundryObject obj in objs) | 28 foreach (IWarFoundryObject obj in objs) |
28 { | 29 { |
29 if (obj is Race) | 30 if (obj is Race) |
30 { | 31 { |
31 raceCount++; | 32 raceCount++; |
32 } | 33 } |
33 else if (obj is GameSystem) | 34 else |
35 if (obj is GameSystem) | |
34 { | 36 { |
35 systemCount++; | 37 systemCount++; |
36 } | 38 } |
37 } | 39 } |
38 | 40 |
52 WarFoundryLoader.SetDefault(loader); | 54 WarFoundryLoader.SetDefault(loader); |
53 WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); | 55 WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); |
54 loader.RegisterFactory(factory); | 56 loader.RegisterFactory(factory); |
55 try | 57 try |
56 { | 58 { |
57 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.race")); | 59 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new LoadableFileObject("testdata/multifile-zips/Test.race")); |
58 Assert.That(objs, Has.Count(2)); | 60 Assert.That(objs, Has.Count(2)); |
59 int raceCount = 0; | 61 int raceCount = 0; |
60 int systemCount = 0; | 62 int systemCount = 0; |
61 | 63 |
62 foreach (IWarFoundryObject obj in objs) | 64 foreach (IWarFoundryObject obj in objs) |
63 { | 65 { |
64 if (obj is Race) | 66 if (obj is Race) |
65 { | 67 { |
66 raceCount++; | 68 raceCount++; |
67 } | 69 } |
68 else if (obj is GameSystem) | 70 else |
71 if (obj is GameSystem) | |
69 { | 72 { |
70 systemCount++; | 73 systemCount++; |
71 } | 74 } |
72 } | 75 } |
73 | 76 |
87 WarFoundryLoader.SetDefault(loader); | 90 WarFoundryLoader.SetDefault(loader); |
88 WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); | 91 WarFoundryXmlFactory factory = WarFoundryXmlFactory.GetFactory(); |
89 loader.RegisterFactory(factory); | 92 loader.RegisterFactory(factory); |
90 try | 93 try |
91 { | 94 { |
92 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Multipack.system")); | 95 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new LoadableFileObject("testdata/multifile-zips/Multipack.system")); |
93 Assert.That(objs, Has.Count(4)); | 96 Assert.That(objs, Has.Count(4)); |
94 int raceCount = 0; | 97 int raceCount = 0; |
95 int systemCount = 0; | 98 int systemCount = 0; |
96 | 99 |
97 foreach (IWarFoundryObject obj in objs) | 100 foreach (IWarFoundryObject obj in objs) |
98 { | 101 { |
99 if (obj is Race) | 102 if (obj is Race) |
100 { | 103 { |
101 raceCount++; | 104 raceCount++; |
102 } | 105 } |
103 else if (obj is GameSystem) | 106 else |
107 if (obj is GameSystem) | |
104 { | 108 { |
105 systemCount++; | 109 systemCount++; |
106 } | 110 } |
107 } | 111 } |
108 | 112 |