Mercurial > repos > IBBoard.WarFoundry.API.Tests
comparison API/Factories/AbstractNativeWarFoundryFactoryTest.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 | 498396c77601 |
children |
comparison
equal
deleted
inserted
replaced
227:d8cd6b259a9f | 228:7c21ca1482cb |
---|---|
7 using System.Diagnostics; | 7 using System.Diagnostics; |
8 using NUnit.Framework.SyntaxHelpers; | 8 using NUnit.Framework.SyntaxHelpers; |
9 using System.IO; | 9 using System.IO; |
10 using IBBoard.WarFoundry.API.Objects; | 10 using IBBoard.WarFoundry.API.Objects; |
11 using System.Collections.Generic; | 11 using System.Collections.Generic; |
12 using IBBoard.WarFoundry.API.Loading; | |
12 | 13 |
13 namespace IBBoard.WarFoundry.API.Factories | 14 namespace IBBoard.WarFoundry.API.Factories |
14 { | 15 { |
15 [TestFixture] | 16 [TestFixture] |
16 public class AbstractNativeWarFoundryFactoryTest | 17 public class AbstractNativeWarFoundryFactoryTest |
18 [Test] | 19 [Test] |
19 public void Bug94TestLoadingTimesForNonZipFiles() | 20 public void Bug94TestLoadingTimesForNonZipFiles() |
20 { | 21 { |
21 MockNativeWarFoundryFactory factory = new MockNativeWarFoundryFactory(); | 22 MockNativeWarFoundryFactory factory = new MockNativeWarFoundryFactory(); |
22 Stopwatch sw = Stopwatch.StartNew(); | 23 Stopwatch sw = Stopwatch.StartNew(); |
23 factory.CreateObjectsFromFile(new FileInfo("testdata/Test.race")); | 24 factory.CreateObjectsFromFile(new LoadableFileObject("testdata/Test.race")); |
24 sw.Stop(); | 25 sw.Stop(); |
25 long successElapsed = sw.ElapsedMilliseconds; | 26 long successElapsed = sw.ElapsedMilliseconds; |
26 sw.Reset(); | 27 sw.Reset(); |
27 sw.Start(); | 28 sw.Start(); |
28 factory.CreateObjectsFromFile(new FileInfo("testdata/NotARaceFile.txt")); | 29 factory.CreateObjectsFromFile(new LoadableFileObject("testdata/NotARaceFile.txt")); |
29 sw.Stop(); | 30 sw.Stop(); |
30 long failedElapsed = sw.ElapsedMilliseconds; | 31 long failedElapsed = sw.ElapsedMilliseconds; |
31 long timeRatio = failedElapsed / successElapsed; | 32 long timeRatio = failedElapsed / successElapsed; |
32 Assert.That(timeRatio, Is.LessThan(10)); | 33 Assert.That(timeRatio, Is.LessThan(10)); |
33 } | 34 } |
37 { | 38 { |
38 MockNativeWarFoundryFactory factory = new MockNativeWarFoundryFactory(); | 39 MockNativeWarFoundryFactory factory = new MockNativeWarFoundryFactory(); |
39 //This will also be triggered by Bug94TestLoadingTimesForNonZipFiles, but this makes it separate and explicit | 40 //This will also be triggered by Bug94TestLoadingTimesForNonZipFiles, but this makes it separate and explicit |
40 FileInfo nonRaceFile = new FileInfo("testdata/NotARaceFile.txt"); | 41 FileInfo nonRaceFile = new FileInfo("testdata/NotARaceFile.txt"); |
41 Assert.That(nonRaceFile.Exists, Is.True); | 42 Assert.That(nonRaceFile.Exists, Is.True); |
42 Assert.That(factory.CanHandleFileFormat(nonRaceFile), Is.False); | 43 Assert.That(factory.CanHandleFileFormat(new LoadableFileObject(nonRaceFile)), Is.False); |
43 } | 44 } |
44 | 45 |
45 [Test] | 46 [Test] |
46 public void Bug380TestLoadingOfOSXesqueFile() | 47 public void Bug380TestLoadingOfOSXesqueFile() |
47 { | 48 { |
48 FileSearchingWarFoundryFactory factory = new FileSearchingWarFoundryFactory(); | 49 FileSearchingWarFoundryFactory factory = new FileSearchingWarFoundryFactory(); |
49 FileInfo file = new FileInfo("testdata/multifile-zips/Test-OSX-style.system"); | 50 FileInfo file = new FileInfo("testdata/multifile-zips/Test-OSX-style.system"); |
50 Assert.That(factory.GetGameSystemZipEntries(file), Has.Count(3)); | 51 Assert.That(factory.GetGameSystemZipEntries(file), Has.Count(3)); |
51 Assert.That(factory.GetRaceZipEntries(file), Has.Count(3)); | 52 Assert.That(factory.GetRaceZipEntries(file), Has.Count(3)); |
52 Assert.That(factory.GetArmyZipEntries(file), Has.Count(3)); | 53 Assert.That(factory.GetArmyZipEntries(file), Has.Count(3)); |
53 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(file); | 54 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(new LoadableFileObject(file)); |
54 Assert.That(objs, Has.Count(0)); | 55 Assert.That(objs, Has.Count(0)); |
55 } | 56 } |
56 } | 57 } |
57 } | 58 } |
58 | 59 |