Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
annotate API/Factories/AbstractNativeWarFoundryFactoryTest.cs @ 227:d8cd6b259a9f
Re #359: Add "only contained" attribute to unit types
* Test to make sure sub-units are removed from the army
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 16 Apr 2012 20:45:45 +0100 |
parents | 498396c77601 |
children | 7c21ca1482cb |
rev | line source |
---|---|
165 | 1 // This file (AbstractNativeWarFoundryFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard |
2 // | |
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. | |
4 using System; | |
5 using NUnit.Framework; | |
6 using IBBoard.WarFoundry.API.Factories.Mock; | |
7 using System.Diagnostics; | |
8 using NUnit.Framework.SyntaxHelpers; | |
9 using System.IO; | |
196
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
10 using IBBoard.WarFoundry.API.Objects; |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
11 using System.Collections.Generic; |
165 | 12 |
13 namespace IBBoard.WarFoundry.API.Factories | |
14 { | |
15 [TestFixture] | |
16 public class AbstractNativeWarFoundryFactoryTest | |
17 { | |
18 [Test] | |
19 public void Bug94TestLoadingTimesForNonZipFiles() | |
20 { | |
21 MockNativeWarFoundryFactory factory = new MockNativeWarFoundryFactory(); | |
22 Stopwatch sw = Stopwatch.StartNew(); | |
23 factory.CreateObjectsFromFile(new FileInfo("testdata/Test.race")); | |
24 sw.Stop(); | |
25 long successElapsed = sw.ElapsedMilliseconds; | |
26 sw.Reset(); | |
27 sw.Start(); | |
167
03ccff4d5e8a
Re #94: Loading files is too slow
IBBoard <dev@ibboard.co.uk>
parents:
166
diff
changeset
|
28 factory.CreateObjectsFromFile(new FileInfo("testdata/NotARaceFile.txt")); |
165 | 29 sw.Stop(); |
30 long failedElapsed = sw.ElapsedMilliseconds; | |
31 long timeRatio = failedElapsed / successElapsed; | |
32 Assert.That(timeRatio, Is.LessThan(10)); | |
33 } | |
166
6b9e86d4be95
Re #358: Handle factory.CreateObjectsFromFile where GetFileAsSupportedType returns null
IBBoard <dev@ibboard.co.uk>
parents:
165
diff
changeset
|
34 |
6b9e86d4be95
Re #358: Handle factory.CreateObjectsFromFile where GetFileAsSupportedType returns null
IBBoard <dev@ibboard.co.uk>
parents:
165
diff
changeset
|
35 [Test] |
6b9e86d4be95
Re #358: Handle factory.CreateObjectsFromFile where GetFileAsSupportedType returns null
IBBoard <dev@ibboard.co.uk>
parents:
165
diff
changeset
|
36 public void Bug358TestLoadingOfFailedFiles() |
6b9e86d4be95
Re #358: Handle factory.CreateObjectsFromFile where GetFileAsSupportedType returns null
IBBoard <dev@ibboard.co.uk>
parents:
165
diff
changeset
|
37 { |
6b9e86d4be95
Re #358: Handle factory.CreateObjectsFromFile where GetFileAsSupportedType returns null
IBBoard <dev@ibboard.co.uk>
parents:
165
diff
changeset
|
38 MockNativeWarFoundryFactory factory = new MockNativeWarFoundryFactory(); |
168 | 39 //This will also be triggered by Bug94TestLoadingTimesForNonZipFiles, but this makes it separate and explicit |
40 FileInfo nonRaceFile = new FileInfo("testdata/NotARaceFile.txt"); | |
41 Assert.That(nonRaceFile.Exists, Is.True); | |
42 Assert.That(factory.CanHandleFileFormat(nonRaceFile), Is.False); | |
166
6b9e86d4be95
Re #358: Handle factory.CreateObjectsFromFile where GetFileAsSupportedType returns null
IBBoard <dev@ibboard.co.uk>
parents:
165
diff
changeset
|
43 } |
196
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
44 |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
45 [Test] |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
46 public void Bug380TestLoadingOfOSXesqueFile() |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
47 { |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
48 FileSearchingWarFoundryFactory factory = new FileSearchingWarFoundryFactory(); |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
49 FileInfo file = new FileInfo("testdata/multifile-zips/Test-OSX-style.system"); |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
50 Assert.That(factory.GetGameSystemZipEntries(file), Has.Count(3)); |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
51 Assert.That(factory.GetRaceZipEntries(file), Has.Count(3)); |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
52 Assert.That(factory.GetArmyZipEntries(file), Has.Count(3)); |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
53 ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(file); |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
54 Assert.That(objs, Has.Count(0)); |
498396c77601
Re #380: WarFoundry chokes on zips written by Mac OS X
IBBoard <dev@ibboard.co.uk>
parents:
168
diff
changeset
|
55 } |
165 | 56 } |
57 } | |
58 |