Mercurial > repos > IBBoard.WarFoundry.API.Tests
comparison API/Factories/Xml/WarFoundryXmlSystemFactoryTest.cs @ 75:72479ca6feb4
Fixes #311: can't read ZIP file packed by Linux app Archive Manager/File Roller
* Add a unit test for the failure
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 30 Oct 2010 14:45:45 +0000 |
parents | a2095a3685fc |
children | 052148dc0a2f |
comparison
equal
deleted
inserted
replaced
74:5bf51f7a28ce | 75:72479ca6feb4 |
---|---|
1 // This file (WarFoundryXmlSystemFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2010 IBBoard | 1 // This file (WarFoundryXmlSystemFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2010 IBBoard |
2 // | 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. | 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 | |
4 using System; | 5 using System; |
5 using NUnit.Framework; | 6 using NUnit.Framework; |
6 using System.IO; | 7 using System.IO; |
7 using IBBoard.WarFoundry.API.Objects; | 8 using IBBoard.WarFoundry.API.Objects; |
8 using NUnit.Framework.SyntaxHelpers; | 9 using NUnit.Framework.SyntaxHelpers; |
13 { | 14 { |
14 [TestFixture()] | 15 [TestFixture()] |
15 public class WarFoundryXmlSystemFactoryTest | 16 public class WarFoundryXmlSystemFactoryTest |
16 { | 17 { |
17 [Test()] | 18 [Test()] |
19 public void TestBug311InvalidVersionToExtract788() | |
20 { | |
21 FileInfo repackFile = new FileInfo("testdata/zip-format/Repack.system"); | |
22 Assert.That(WarFoundryXmlFactory.GetFactory().CanHandleFileAsGameSystem(repackFile), Is.True); | |
23 Assert.That(WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(repackFile), Has.Count(1)); | |
24 } | |
25 | |
26 [Test()] | |
18 public void TestGettingDefaultStatsIDFullyLoadsGameSystem() | 27 public void TestGettingDefaultStatsIDFullyLoadsGameSystem() |
19 { | 28 { |
20 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); | 29 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); |
21 Assert.That(system.IsFullyLoaded, Is.False); | 30 Assert.That(system.IsFullyLoaded, Is.False); |
22 string defaultStatsID = system.StandardSystemStatsID; | 31 string defaultStatsID = system.StandardSystemStatsID; |
23 Assert.That(defaultStatsID, Is.Not.Null); | 32 Assert.That(defaultStatsID, Is.Not.Null); |
24 Assert.That(defaultStatsID, Is.Not.Empty); | 33 Assert.That(defaultStatsID, Is.Not.Empty); |
25 Assert.That(system.IsFullyLoaded, Is.True); | 34 Assert.That(system.IsFullyLoaded, Is.True); |
26 } | 35 } |
27 | 36 |
28 [Test()] | 37 [Test()] |
29 public void TestValidDefaultStatsIDLoadsCorrectly() | 38 public void TestValidDefaultStatsIDLoadsCorrectly() |
30 { | 39 { |
31 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); | 40 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-one-stats-set.systemx")); |
32 Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); | 41 Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); |
33 Assert.That(system.SystemStats, Has.Length(1)); | 42 Assert.That(system.SystemStats, Has.Length(1)); |
34 } | 43 } |
35 | 44 |
36 [Test()] | 45 [Test()] |
37 public void TestValidDefaultStatsIDLoadsCorrectlyWithMultipleStatsSets() | 46 public void TestValidDefaultStatsIDLoadsCorrectlyWithMultipleStatsSets() |
38 { | 47 { |
39 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx")); | 48 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-default-stats-multiple-stats-set.systemx")); |
40 Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); | 49 Assert.That(system.StandardSystemStatsID, Is.EqualTo("defaultStats")); |
41 Assert.That(system.SystemStats, Has.Length(2)); | 50 Assert.That(system.SystemStats, Has.Length(2)); |
42 } | 51 } |
43 | 52 |
44 [Test()] | 53 [Test()] |
45 public void TestIncorrectDefaultStatsIDErrors() | 54 public void TestIncorrectDefaultStatsIDErrors() |
46 { | 55 { |
47 TestFileValidationFailure("testdata/xml-system-factory/invalid-default-stats.systemx"); | 56 TestFileValidationFailure("testdata/xml-system-factory/invalid-default-stats.systemx"); |
48 } | 57 } |
49 | 58 |
50 [Test()] | 59 [Test()] |
51 public void TestDuplicateStatsIDErrors() | 60 public void TestDuplicateStatsIDErrors() |
52 { | 61 { |
53 TestFileValidationFailure("testdata/xml-system-factory/duplicate-stats-set-id.systemx"); | 62 TestFileValidationFailure("testdata/xml-system-factory/duplicate-stats-set-id.systemx"); |
54 } | 63 } |
55 | 64 |
56 [Test()] | 65 [Test()] |
57 public void TestValidCategoriesLoadsCorrectly() | 66 public void TestValidCategoriesLoadsCorrectly() |
58 { | 67 { |
59 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-categories.systemx")); | 68 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-system-factory/valid-categories.systemx")); |
60 Assert.That(system.Categories, Has.Length(5)); | 69 Assert.That(system.Categories, Has.Length(5)); |
61 } | 70 } |
62 | 71 |
63 [Test()] | 72 [Test()] |
64 public void TestDuplicateCategoryIDErrors() | 73 public void TestDuplicateCategoryIDErrors() |
65 { | 74 { |
66 TestFileValidationFailure("testdata/xml-system-factory/duplicate-category-ids.systemx"); | 75 TestFileValidationFailure("testdata/xml-system-factory/duplicate-category-ids.systemx"); |
67 } | 76 } |
68 | 77 |
69 private void TestFileValidationFailure(string filePath) | 78 private void TestFileValidationFailure(string filePath) |
70 { | 79 { |
71 FileInfo systemFile = new FileInfo(filePath); | 80 FileInfo systemFile = new FileInfo(filePath); |
72 | 81 |
73 try | 82 try |