Mercurial > repos > IBBoard.WarFoundry.API.Tests
annotate API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 80:102887bd063b
Fixes #139: Load additional data for units
* Already done and loaded
* Minor change to unit test to make sure we're loading something and not just returning empty strings
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 26 Jan 2011 20:10:02 +0000 |
parents | d1d79adcb11d |
children | 1de37b5c8107 |
rev | line source |
---|---|
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (WarFoundryXmlRaceFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
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. |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
57
745820ad7656
Re #274: Crash when missing unit member ID
IBBoard <dev@ibboard.co.uk>
parents:
51
diff
changeset
|
5 using System; |
745820ad7656
Re #274: Crash when missing unit member ID
IBBoard <dev@ibboard.co.uk>
parents:
51
diff
changeset
|
6 using System.Collections.Generic; |
745820ad7656
Re #274: Crash when missing unit member ID
IBBoard <dev@ibboard.co.uk>
parents:
51
diff
changeset
|
7 using System.IO; |
745820ad7656
Re #274: Crash when missing unit member ID
IBBoard <dev@ibboard.co.uk>
parents:
51
diff
changeset
|
8 using System.Xml.Schema; |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
9 using IBBoard.IO; |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
10 using IBBoard.WarFoundry.API.Objects; |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
11 using NUnit.Framework; |
50
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
12 using NUnit.Framework.SyntaxHelpers; |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 namespace IBBoard.WarFoundry.API.Factories.Xml |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
57
745820ad7656
Re #274: Crash when missing unit member ID
IBBoard <dev@ibboard.co.uk>
parents:
51
diff
changeset
|
16 //It would be better to explicitly check that some of these errors are certain types of schema validation error, but Mono and .Net have |
745820ad7656
Re #274: Crash when missing unit member ID
IBBoard <dev@ibboard.co.uk>
parents:
51
diff
changeset
|
17 //different exception messages for the same text and just have one class for all schema exceptions of all types. |
58
c642d217036e
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
18 //We can't even check line numbers because Mono embeds them in the text and the actual line number is the end of the file. |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 [TestFixture()] |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 public class WarFoundryXmlRaceFactoryTest |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 { |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
22 [TearDown()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
23 public void AfterTestCleanup() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
24 { |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
25 WarFoundryLoader.SetDefault(null); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
26 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
27 |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 [Test()] |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
29 public void TestCompleteLoadingOnRaceWithMissingAbilityIdErrors() |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
31 TestFileValidationFailure("testdata/xml-race-factory/non-existant-ability.racex"); |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
32 } |
61
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
33 |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
34 [Test()] |
62
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
35 public void TestCompleteLoadingOnRaceWithDuplicateAbilityIdErrors() |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
36 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
37 TestFileValidationFailure("testdata/xml-race-factory/duplicate-ability.racex"); |
62
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
38 } |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
39 |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
40 [Test()] |
61
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
41 public void TestCompleteLoadingOnRaceWithAbilityLoadsData() |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
42 { |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
43 SetDefaultGameSystem(); |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
44 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-ability.racex"); |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
45 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
46 UnitType unitType = race.GetUnitType("Empire1"); |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
47 Ability ability = race.GetAbility("leaderOfMen"); |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
48 Assert.That(ability.Name, Is.EqualTo("Leader of Men")); |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
49 Assert.That(ability.Description, Is.EqualTo("All men will follow the character and can use his leadership")); |
62
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
50 Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability)); |
61
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
51 } |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
52 |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
53 [Test()] |
62
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
54 public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDErrors() |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
55 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
56 TestFileValidationFailure("testdata/xml-race-factory/non-existant-member-type.racex"); |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 } |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
58 |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
59 [Test()] |
62
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
60 public void TestCompleteLoadingOnRaceWithDuplicateMemberTypeIDErrors() |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
61 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
62 TestFileValidationFailure("testdata/xml-race-factory/duplicate-member-type.racex"); |
62
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
63 } |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
64 |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
65 [Test()] |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
66 public void TestCompleteLoadingOnRaceWithMemberTypeLoadsData() |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
67 { |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
68 SetDefaultGameSystem(); |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
69 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-member-type.racex"); |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
70 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
71 UnitMemberType memberType = race.GetUnitMemberType("General"); |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
72 Assert.That(memberType.Name, Is.EqualTo("General")); |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
73 } |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
74 |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
75 [Test()] |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
76 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors() |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
77 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
78 TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-invalid-equipment-slot-reference.racex"); |
59
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
79 } |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
80 |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
81 [Test()] |
66
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
82 public void TestCompleteLoadingOnRaceWithDuplicateEquipmentSlotErrors() |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
83 { |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
84 TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-duplicate-equipment-slot.racex"); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
85 } |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
86 |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
87 [Test()] |
63
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
88 public void TestCompleteLoadingOnRaceWithCorrectEquipmentSlotLoads() |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
89 { |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
90 SetDefaultGameSystem(); |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
91 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/single-unit-with-valid-equipment-slot-reference.racex"); |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
92 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
64
6f638d6f400f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
93 UnitType unitType = race.GetUnitType("Empire1"); |
6f638d6f400f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
94 UnitEquipmentItem unitEquipmentItem = unitType.GetEquipmentItem("Empire1equip1"); |
63
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
95 Assert.That(unitEquipmentItem.SlotName, Is.EqualTo("slot1")); |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
96 } |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
97 |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
98 [Test()] |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
99 public void TestCompleteLoadingOnRaceWithNoEquipmentSlotLimitErrors() |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
100 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
101 TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-no-equipment-slot-limit.racex"); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
102 } |
63
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
103 |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
104 [Test()] |
59
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
105 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentIDError() |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
106 { |
66
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
107 TestFileValidationFailure("testdata/xml-race-factory/single-unit-with-invalid-equipment-reference.racex"); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
108 } |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
109 |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
110 [Test()] |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
111 public void TestCompleteLoadingOnRaceWithDuplicateEquipmentIDError() |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
112 { |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
113 TestFileValidationFailure("testdata/xml-race-factory/duplicate-equipment-id.racex"); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
114 } |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
115 |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
116 [Test()] |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
117 public void TestCompleteLoadingOnRaceWithCorrectEquipmentIDLoads() |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
118 { |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
119 SetDefaultGameSystem(); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
120 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/single-unit-with-valid-equipment-reference.racex"); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
121 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
122 UnitType unitType = race.GetUnitType("Empire1"); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
123 Assert.That(unitType.GetEquipmentItem("Empire1equip1"), Is.Not.Null); |
59
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
124 } |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
125 |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
126 [Test()] |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
127 public void TestCompleteLoadingOnRaceWithIncorrectContainedUnitIDError() |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
128 { |
66
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
129 TestFileValidationFailure("testdata/xml-race-factory/invalid-contained-unit-reference.racex"); |
59
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
130 } |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
131 |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
132 [Test()] |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
133 public void TestCompleteLoadingOnRaceWithCorrectContainedUnitIDLoadsData() |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
134 { |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
135 SetDefaultGameSystem(); |
66
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
136 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/valid-contained-unit-reference.racex"); |
59
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
137 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
138 UnitType unitType = race.GetUnitType("Empire1"); |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
139 Assert.That(unitType.ContainedUnitTypes, Has.Length(1)); |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
140 } |
60
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
141 |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
142 [Test()] |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
143 public void TestCompleteLoadingOnRaceWithDuplicateExtraDataKeyErrors() |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
144 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
145 TestFileValidationFailure("testdata/xml-race-factory/duplicate-extra-data-key.racex"); |
60
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
146 } |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
147 |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
148 [Test()] |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
149 public void TestCompleteLoadingOnRaceWithDifferentExtraDataKeysLoadsData() |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
150 { |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
151 SetDefaultGameSystem(); |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
152 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/different-extra-data-key.racex"); |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
153 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
154 UnitType unitType = race.GetUnitType("Empire1"); |
80
102887bd063b
Fixes #139: Load additional data for units
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
155 Assert.That(unitType.GetExtraData("data1"), Is.EqualTo("SomeStringHere")); |
60
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
156 } |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
157 |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
158 [Test()] |
35
4302e6b2c5c1
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
33
diff
changeset
|
159 [ExpectedException(typeof(InvalidFileException), ExpectedMessage="Referenced game system, 'nonexistant-system', did not exist")] |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
160 public void TestCompleteLoadingOnRaceWithMissingGameSystemErrors() |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 { |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/race-with-non-existant-game-system.race")); |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 Assert.AreEqual(1, objs.Count); |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 IEnumerator<IWarFoundryObject> enumerator = objs.GetEnumerator(); |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 enumerator.Reset(); |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 enumerator.MoveNext(); |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 Race race = (Race)enumerator.Current; |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
168 race.EnsureFullyLoaded(); |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 } |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
170 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
171 [Test()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
172 public void TestSingleUnitArmyLoadsSuccessfully() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
173 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
174 SetDefaultGameSystem(); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
175 FileInfo raceFile = new FileInfo("testdata/single-unit-race.racex"); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
176 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
51
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
177 Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
178 UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
179 Assert.AreEqual(1, unitTypes.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
180 UnitType unitType = unitTypes[0]; |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
181 Stat[] stats = unitType.UnitStatsArrays[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
182 Assert.AreEqual(9, stats.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
183 Assert.AreEqual("M", stats[0].ParentSlotName); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
184 Assert.AreEqual("4", stats[0].SlotValueString); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
185 Assert.AreEqual("Empire General", unitType.UnitStatsArraysWithName[0][0].SlotValueString); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
186 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
187 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
188 [Test()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
189 public void TestSingleUnitArmyWithMemberTypeReferenceLoadsSuccessfully() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
190 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
191 SetDefaultGameSystem(); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
192 FileInfo raceFile = new FileInfo("testdata/single-unit-type-referencing-race.racex"); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
193 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
51
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
194 Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
195 UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
196 Assert.AreEqual(1, unitTypes.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
197 UnitType unitType = unitTypes[0]; |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
198 Stat[] stats = unitType.UnitStatsArrays[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
199 Assert.AreEqual(9, stats.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
200 Assert.AreEqual("M", stats[0].ParentSlotName); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
201 Assert.AreEqual("4", stats[0].SlotValueString); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
202 Assert.AreEqual("General", unitType.UnitStatsArraysWithName[0][0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
203 } |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
204 |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
205 [Test()] |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
206 public void TestSingleUnitArmyWithMultipleMemberTypeReferencesLoadsSuccessfully() |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
207 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
208 SetDefaultGameSystem(); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
209 FileInfo raceFile = new FileInfo("testdata/single-unit-multi-type-referencing-race.racex"); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
210 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
51
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
211 Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
212 UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
213 Assert.AreEqual(1, unitTypes.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
214 UnitType unitType = unitTypes[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
215 Stat[][] stats = unitType.UnitStatsArrays; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
216 Assert.AreEqual(2, stats.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
217 Assert.AreEqual("M", stats[0][0].ParentSlotName); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
218 Assert.AreEqual("4", stats[0][0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
219 Assert.AreEqual("General", unitType.UnitStatsArraysWithName[0][0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
220 Assert.AreEqual("M", stats[1][0].ParentSlotName); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
221 Assert.AreEqual("8", stats[1][0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
222 Assert.AreEqual("Warhorse", unitType.UnitStatsArraysWithName[1][0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
223 } |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
224 |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
225 [Test()] |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
226 public void TestSingleUnitArmyWithMultipleMemberTypeReferencesAndOverrideLoadsSuccessfully() |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
227 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
228 SetDefaultGameSystem(); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
229 FileInfo raceFile = new FileInfo("testdata/single-unit-multi-type-referencing-race-with-override.racex"); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
230 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
51
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
231 Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
232 UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
233 Assert.AreEqual(1, unitTypes.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
234 UnitType unitType = unitTypes[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
235 Stat[][] allStats = unitType.UnitStatsArrays; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
236 Stat[] stats = allStats[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
237 Assert.AreEqual(1, allStats.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
238 Assert.AreEqual(9, stats.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
239 Assert.AreEqual("M", stats[0].ParentSlotName); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
240 Assert.AreEqual("4", stats[0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
241 Assert.AreEqual("Empire General", unitType.UnitStatsArraysWithName[0][0].SlotValueString); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
242 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
243 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
244 [Test()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
245 public void TestSingleUnitArmyWithNoStatsReturnsUnitWithBlankStats() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
246 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
247 SetDefaultGameSystem(); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
248 FileInfo raceFile = new FileInfo("testdata/single-unit-no-stats-race.racex"); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
249 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
51
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
250 Assert.That(race.GetUnitType("Empire1"), Is.Not.Null); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
251 UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
252 Assert.AreEqual(1, unitTypes.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
253 UnitType unitType = unitTypes[0]; |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
254 Stat[] stats = unitType.UnitStatsArrays[0]; |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
255 Assert.That(stats.Length == race.GameSystem.StandardSystemStats.SlotCount); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
256 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
257 foreach (Stat stat in stats) |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
258 { |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
259 Assert.AreEqual("", stat.SlotValueString); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
260 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
261 |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
262 Assert.AreEqual("Empire General", unitType.UnitStatsArraysWithName[0][0].SlotValueString); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
263 } |
50
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
264 |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
265 [Test()] |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
266 public void TestSingleUnitArmyWithNoCategoriesUsesMainCategory() |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
267 { |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
268 SetDefaultGameSystem(); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
269 FileInfo raceFile = new FileInfo("testdata/single-unit-no-category.racex"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
270 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
271 Category category = race.GetCategory("cat1"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
272 UnitType[] unitTypes = race.GetUnitTypes(category); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
273 Assert.AreEqual(1, unitTypes.Length); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
274 UnitType unitType = unitTypes[0]; |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
275 Assert.That(unitType.MainCategory, Is.EqualTo(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
276 Assert.That(unitType.Categories.Length, Is.EqualTo(1)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
277 Assert.That(unitType.Categories, Has.Member(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
278 } |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
279 |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
280 [Test()] |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
281 public void TestSingleUnitArmyWithOneCategoryAndSameMainCategoryHasOneCategory() |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
282 { |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
283 SetDefaultGameSystem(); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
284 FileInfo raceFile = new FileInfo("testdata/single-unit-one-category-same-main-category.racex"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
285 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
286 Category category = race.GetCategory("cat1"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
287 UnitType[] unitTypes = race.GetUnitTypes(category); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
288 Assert.AreEqual(1, unitTypes.Length); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
289 UnitType unitType = unitTypes[0]; |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
290 Assert.That(unitType.MainCategory, Is.EqualTo(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
291 Assert.That(unitType.Categories.Length, Is.EqualTo(1)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
292 Assert.That(unitType.Categories, Has.Member(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
293 } |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
294 |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
295 [Test()] |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
296 public void TestSingleUnitArmyWithOneCategoryAndDifferentMainCategoryHasTwoCategories() |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
297 { |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
298 SetDefaultGameSystem(); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
299 FileInfo raceFile = new FileInfo("testdata/single-unit-one-category-different-main-category.racex"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
300 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
301 Category category = race.GetCategory("cat1"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
302 UnitType[] unitTypes = race.GetUnitTypes(category); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
303 Assert.AreEqual(1, unitTypes.Length); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
304 UnitType unitType = unitTypes[0]; |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
305 Assert.That(unitType.MainCategory, Is.EqualTo(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
306 Assert.That(unitType.Categories.Length, Is.EqualTo(2)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
307 Assert.That(unitType.Categories, Has.Member(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
308 Assert.That(unitType.Categories, Has.Member(race.GetCategory("cat2"))); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
309 } |
51
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
310 |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
311 [Test()] |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
312 public void TestSingleUnitArmyWithMultipleCategoriesIsInEachCategory() |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
313 { |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
314 SetDefaultGameSystem(); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
315 FileInfo raceFile = new FileInfo("testdata/single-unit-two-categories.racex"); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
316 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
317 UnitType unitType = race.GetUnitType("Empire1"); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
318 Assert.That(unitType.Categories.Length, Is.EqualTo(2)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
319 Category cat1 = race.GetCategory("cat1"); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
320 Category cat2 = race.GetCategory("cat2"); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
321 Assert.That(unitType.MainCategory, Is.EqualTo(cat1)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
322 Assert.That(unitType.Categories, Has.Member(cat1)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
323 Assert.That(unitType.Categories, Has.Member(cat2)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
324 Assert.That(race.GetUnitTypes(cat1), Is.All.EqualTo(unitType)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
325 UnitType[] unitTypesCat2 = race.GetUnitTypes(cat2); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
326 Assert.That(unitTypesCat2, Has.Length(1)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
327 Assert.That(unitTypesCat2, Is.All.EqualTo(unitType)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
328 } |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
329 |
72
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
330 [Test()] |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
331 public void TestValidCategoriesLoadsCorrectly() |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
332 { |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
333 SetDefaultGameSystem(); |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
334 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/valid-categories.racex")); |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
335 Assert.That(race.Categories, Has.Length(5)); |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
336 } |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
337 |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
338 [Test()] |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
339 public void TestDuplicateCategoryIDErrors() |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
340 { |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
341 TestFileValidationFailure("testdata/xml-race-factory/duplicate-category-ids.racex"); |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
342 } |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
343 |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
344 private void TestFileValidationFailure(string filePath) |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
345 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
346 SetDefaultGameSystem(); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
347 FileInfo raceFile = new FileInfo(filePath); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
348 |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
349 try |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
350 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
351 SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
352 Assert.Fail("Excepted exception not thrown"); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
353 } |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
354 catch (InvalidFileException ex) |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
355 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
356 Console.WriteLine(ex.Message); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
357 Exception innerException = ex.InnerException; |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
358 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
359 } |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
360 } |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
361 |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
362 private static void SetDefaultGameSystem() |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
363 { |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
364 SetDefaultGameSystem(new FileInfo("testdata/default.systemx")); |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
365 } |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
366 |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
367 public static void SetDefaultGameSystem(FileInfo systemFile) |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
368 { |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
369 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), systemFile); |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
370 FixedGameSystemWarFoundryLoader fixedLoader = new FixedGameSystemWarFoundryLoader(system); |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
371 WarFoundryLoader.SetDefault(fixedLoader); |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
372 } |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
373 } |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
374 } |