Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
annotate API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 237:833f72be715a
* Remove rogue print statements
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 06 Nov 2012 20:58:48 +0000 |
parents | 7c21ca1482cb |
children | e173c5512067 |
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; |
149
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
13 using IBBoard.WarFoundry.API.Objects.Requirement; |
158
d0b8c43f705f
Fixes #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
149
diff
changeset
|
14 using IBBoard.WarFoundry.API.Factories.Requirement; |
228
7c21ca1482cb
Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents:
225
diff
changeset
|
15 using IBBoard.WarFoundry.API.Loading; |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 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
|
18 { |
57
745820ad7656
Re #274: Crash when missing unit member ID
IBBoard <dev@ibboard.co.uk>
parents:
51
diff
changeset
|
19 //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
|
20 //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
|
21 //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
|
22 [TestFixture()] |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 public class WarFoundryXmlRaceFactoryTest |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 { |
158
d0b8c43f705f
Fixes #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
149
diff
changeset
|
25 [SetUp()] |
d0b8c43f705f
Fixes #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
149
diff
changeset
|
26 public void RegisterRequirementHandler() |
d0b8c43f705f
Fixes #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
149
diff
changeset
|
27 { |
d0b8c43f705f
Fixes #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
149
diff
changeset
|
28 WarFoundryLoader.RegisterRequirementFactory(new UnitRequiresAtLeastNUnitsRequirementFactory()); |
d0b8c43f705f
Fixes #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
149
diff
changeset
|
29 } |
d0b8c43f705f
Fixes #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
149
diff
changeset
|
30 |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
31 [TearDown()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
32 public void AfterTestCleanup() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
33 { |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
34 WarFoundryLoader.SetDefault(null); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
35 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
36 |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 [Test()] |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
38 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
|
39 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
40 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
|
41 } |
61
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 [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
|
44 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
|
45 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
46 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
|
47 } |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
48 |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
49 [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
|
50 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
|
51 { |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
52 SetDefaultGameSystem(); |
27625216d8d6
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 } |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
61 |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
62 [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
|
63 public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDErrors() |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
64 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
65 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
|
66 } |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
67 |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
68 [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
|
69 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
|
70 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
71 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
|
72 } |
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 [Test()] |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
75 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
|
76 { |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
77 SetDefaultGameSystem(); |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 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
|
82 } |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
83 |
ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
84 [Test()] |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
85 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors() |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
86 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
87 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
|
88 } |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
89 |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
90 [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
|
91 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
|
92 { |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
93 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
|
94 } |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
95 |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
96 [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
|
97 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
|
98 { |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
99 SetDefaultGameSystem(); |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 } |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
106 |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
107 [Test()] |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
108 public void TestCompleteLoadingOnRaceWithNoEquipmentSlotLimitErrors() |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
109 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
110 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
|
111 } |
63
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
112 |
a9163f8dfba1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
113 [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
|
114 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
|
115 { |
66
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
116 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
|
117 } |
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 [Test()] |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
120 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
|
121 { |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
122 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
|
123 } |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
124 |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
125 [Test()] |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
126 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
|
127 { |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
128 SetDefaultGameSystem(); |
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 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
|
133 } |
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 [Test()] |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
136 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
|
137 { |
66
f671ead260b1
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
138 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
|
139 } |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
140 |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
141 [Test()] |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
142 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
|
143 { |
6efa080b500f
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 } |
60
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 [Test()] |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
152 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
|
153 { |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
154 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
|
155 } |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
156 |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
157 [Test()] |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
158 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
|
159 { |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
160 SetDefaultGameSystem(); |
f2348c00e633
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
161 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
|
162 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
|
163 UnitType unitType = race.GetUnitType("Empire1"); |
80
102887bd063b
Fixes #139: Load additional data for units
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
164 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
|
165 } |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 [Test()] |
35
4302e6b2c5c1
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
33
diff
changeset
|
168 [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
|
169 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
|
170 { |
228
7c21ca1482cb
Re #419: Remove assumptions of a file-based install
IBBoard <dev@ibboard.co.uk>
parents:
225
diff
changeset
|
171 ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new LoadableFileObject(new FileInfo("testdata/race-with-non-existant-game-system.race"))); |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 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
|
173 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
|
174 enumerator.Reset(); |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 enumerator.MoveNext(); |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 Race race = (Race)enumerator.Current; |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
177 race.EnsureFullyLoaded(); |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 } |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
179 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
180 [Test()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
181 public void TestSingleUnitArmyLoadsSuccessfully() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
182 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
183 SetDefaultGameSystem(); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
184 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
|
185 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
|
186 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
|
187 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
|
188 Assert.AreEqual(1, unitTypes.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
189 UnitType unitType = unitTypes[0]; |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
190 Stat[] stats = unitType.UnitStatsArrays[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
191 Assert.AreEqual(9, stats.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
192 Assert.AreEqual("M", stats[0].ParentSlotName); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
193 Assert.AreEqual("4", stats[0].SlotValueString); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
194 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
|
195 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
196 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
197 [Test()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
198 public void TestSingleUnitArmyWithMemberTypeReferenceLoadsSuccessfully() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
199 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
200 SetDefaultGameSystem(); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 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
|
205 Assert.AreEqual(1, unitTypes.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
206 UnitType unitType = unitTypes[0]; |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
207 Stat[] stats = unitType.UnitStatsArrays[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
208 Assert.AreEqual(9, stats.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
209 Assert.AreEqual("M", stats[0].ParentSlotName); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
210 Assert.AreEqual("4", stats[0].SlotValueString); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
211 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
|
212 } |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
213 |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
214 [Test()] |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
215 public void TestSingleUnitArmyWithMultipleMemberTypeReferencesLoadsSuccessfully() |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
216 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
217 SetDefaultGameSystem(); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
218 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
|
219 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
|
220 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
|
221 UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
222 Assert.AreEqual(1, unitTypes.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
223 UnitType unitType = unitTypes[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
224 Stat[][] stats = unitType.UnitStatsArrays; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
225 Assert.AreEqual(2, stats.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
226 Assert.AreEqual("M", stats[0][0].ParentSlotName); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
227 Assert.AreEqual("4", stats[0][0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
228 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
|
229 Assert.AreEqual("M", stats[1][0].ParentSlotName); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
230 Assert.AreEqual("8", stats[1][0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
231 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
|
232 } |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
233 |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
234 [Test()] |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
235 public void TestSingleUnitArmyWithMultipleMemberTypeReferencesAndOverrideLoadsSuccessfully() |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
236 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
237 SetDefaultGameSystem(); |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
238 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
|
239 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
|
240 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
|
241 UnitType[] unitTypes = race.GetUnitTypes(race.GetCategory("cat1")); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
242 Assert.AreEqual(1, unitTypes.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
243 UnitType unitType = unitTypes[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
244 Stat[][] allStats = unitType.UnitStatsArrays; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
245 Stat[] stats = allStats[0]; |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
246 Assert.AreEqual(1, allStats.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
247 Assert.AreEqual(9, stats.Length); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
248 Assert.AreEqual("M", stats[0].ParentSlotName); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
249 Assert.AreEqual("4", stats[0].SlotValueString); |
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
250 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
|
251 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
252 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
253 [Test()] |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
254 public void TestSingleUnitArmyWithNoStatsReturnsUnitWithBlankStats() |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
255 { |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
256 SetDefaultGameSystem(); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 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
|
261 Assert.AreEqual(1, unitTypes.Length); |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
262 UnitType unitType = unitTypes[0]; |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
263 Stat[] stats = unitType.UnitStatsArrays[0]; |
43
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
264 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
|
265 |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
266 foreach (Stat stat in stats) |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
267 { |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
268 Assert.AreEqual("", stat.SlotValueString); |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
269 } |
00abd1c2f7d6
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
270 |
44
0de5d86bc1cb
Re #268: Restructure stats for re-use
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
271 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
|
272 } |
50
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
273 |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
274 [Test()] |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
275 public void TestSingleUnitArmyWithNoCategoriesUsesMainCategory() |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
276 { |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
277 SetDefaultGameSystem(); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
278 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
|
279 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
280 Category category = race.GetCategory("cat1"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
281 UnitType[] unitTypes = race.GetUnitTypes(category); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
282 Assert.AreEqual(1, unitTypes.Length); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
283 UnitType unitType = unitTypes[0]; |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
284 Assert.That(unitType.MainCategory, Is.EqualTo(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
285 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
|
286 Assert.That(unitType.Categories, Has.Member(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
287 } |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
288 |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
289 [Test()] |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
290 public void TestSingleUnitArmyWithOneCategoryAndSameMainCategoryHasOneCategory() |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
291 { |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
292 SetDefaultGameSystem(); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
293 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
|
294 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
295 Category category = race.GetCategory("cat1"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
296 UnitType[] unitTypes = race.GetUnitTypes(category); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
297 Assert.AreEqual(1, unitTypes.Length); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
298 UnitType unitType = unitTypes[0]; |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
299 Assert.That(unitType.MainCategory, Is.EqualTo(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
300 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
|
301 Assert.That(unitType.Categories, Has.Member(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
302 } |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
303 |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
304 [Test()] |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
305 public void TestSingleUnitArmyWithOneCategoryAndDifferentMainCategoryHasTwoCategories() |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
306 { |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
307 SetDefaultGameSystem(); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
308 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
|
309 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
310 Category category = race.GetCategory("cat1"); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
311 UnitType[] unitTypes = race.GetUnitTypes(category); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
312 Assert.AreEqual(1, unitTypes.Length); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
313 UnitType unitType = unitTypes[0]; |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
314 Assert.That(unitType.MainCategory, Is.EqualTo(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
315 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
|
316 Assert.That(unitType.Categories, Has.Member(category)); |
d3519f38a0f4
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
317 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
|
318 } |
51
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
319 |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
320 [Test()] |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
321 public void TestSingleUnitArmyWithMultipleCategoriesIsInEachCategory() |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
322 { |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
323 SetDefaultGameSystem(); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
324 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
|
325 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
326 UnitType unitType = race.GetUnitType("Empire1"); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
327 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
|
328 Category cat1 = race.GetCategory("cat1"); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
329 Category cat2 = race.GetCategory("cat2"); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
330 Assert.That(unitType.MainCategory, Is.EqualTo(cat1)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
331 Assert.That(unitType.Categories, Has.Member(cat1)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
332 Assert.That(unitType.Categories, Has.Member(cat2)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
333 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
|
334 UnitType[] unitTypesCat2 = race.GetUnitTypes(cat2); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
335 Assert.That(unitTypesCat2, Has.Length(1)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
336 Assert.That(unitTypesCat2, Is.All.EqualTo(unitType)); |
9d68b5dd70b3
Re #270: Add multiple categories to API
IBBoard <dev@ibboard.co.uk>
parents:
50
diff
changeset
|
337 } |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
338 |
72
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
339 [Test()] |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
340 public void TestValidCategoriesLoadsCorrectly() |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
341 { |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
342 SetDefaultGameSystem(); |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
343 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
|
344 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
|
345 } |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
346 |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
347 [Test()] |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
348 public void TestDuplicateCategoryIDErrors() |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
349 { |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
350 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
|
351 } |
d1d79adcb11d
Re #297: Move Categories over to key/keyref from ID/IDREF
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
352 |
147
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
353 [Test()] |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
354 public void TestExtendedRequirementsPassValidation() |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
355 { |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
356 SetDefaultGameSystem(); |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
357 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/extended-requirements.racex")); |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
358 Assert.That(race.Categories, Has.Length(5)); |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
359 } |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
360 |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
361 [Test()] |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
362 public void TestLoadingSimpleRequirement() |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
363 { |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
364 SetDefaultGameSystem(); |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
365 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/simple-requirement.racex")); |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
366 UnitType unitType = race.GetUnitType("Empire1"); |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
367 Assert.That(unitType.GetRequirements(), Has.Length(1)); |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
368 } |
1de37b5c8107
Re #346: Add core schema support for requirements
IBBoard <dev@ibboard.co.uk>
parents:
80
diff
changeset
|
369 |
149
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
370 [Test()] |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
371 public void TestLoadingRequirementType() |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
372 { |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
373 SetDefaultGameSystem(); |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
374 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/simple-requirement.racex")); |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
375 UnitType unitType = race.GetUnitType("Empire1"); |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
376 Assert.That(unitType.GetRequirements()[0], Is.InstanceOfType(typeof(UnitRequiresAtLeastNUnitsRequirement))); |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
377 } |
71b9364f0276
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
378 |
203
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
379 [Test] |
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
380 public void TestCyclicReferenceDoesNotCrash() |
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
381 { |
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
382 SetDefaultGameSystem(); |
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
383 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/cyclic.racex")); |
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
384 UnitType unitType = race.GetUnitType("Empire1"); |
204
ea104de9189e
Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents:
203
diff
changeset
|
385 Assert.That(unitType.GetRequirements()[0], Is.InstanceOfType(typeof(UnitRequiresNoMoreThanNOfUnitTypeRequirement))); |
203
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
386 } |
2b27447ae74e
Re #352: Test/fix cyclic references in unit types
IBBoard <dev@ibboard.co.uk>
parents:
158
diff
changeset
|
387 |
225
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
388 [Test] |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
389 public void TestContainedUnitsAreLoaded() |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
390 { |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
391 SetDefaultGameSystem(); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
392 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/with-contained-only-unit.racex")); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
393 Assert.That(race.GetUnitType("Empire2"), Is.Not.Null); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
394 UnitType unitType1 = race.GetUnitType("Empire1"); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
395 Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Length(1)); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
396 Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType1)); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
397 } |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
398 |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
399 [Test] |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
400 public void TestMixedContainedUnitsAreLoaded() |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
401 { |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
402 SetDefaultGameSystem(); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
403 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), new FileInfo("testdata/xml-race-factory/with-mixed-contained-units.racex")); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
404 Assert.That(race.GetUnitType("Empire2"), Is.Not.Null); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
405 UnitType unitType1 = race.GetUnitType("Empire1"); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
406 UnitType unitType3 = race.GetUnitType("Empire3"); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
407 Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Length(2)); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
408 Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType1)); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
409 Assert.That(race.GetUnitTypes(race.GetCategory("cat1")), Has.Member(unitType3)); |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
410 } |
c6313a2c08a2
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
204
diff
changeset
|
411 |
65
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
412 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
|
413 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
414 SetDefaultGameSystem(); |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
415 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
|
416 |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
417 try |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
418 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
419 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
|
420 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
|
421 } |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
422 catch (InvalidFileException ex) |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
423 { |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
424 Exception innerException = ex.InnerException; |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
425 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
|
426 } |
fa536aee66d7
Fixes #296: Fix handling of equipment slot with no limit
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
427 } |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
428 |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
429 private static void SetDefaultGameSystem() |
47
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
430 { |
b4b4bde843d7
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
431 SetDefaultGameSystem(new FileInfo("testdata/default.systemx")); |
45
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
432 } |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
433 |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
434 public static void SetDefaultGameSystem(FileInfo systemFile) |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
435 { |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
436 GameSystem system = SingleXmlObjectLoader.LoadGameSystemFromXML(WarFoundryXmlFactory.GetFactory(), systemFile); |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
437 FixedGameSystemWarFoundryLoader fixedLoader = new FixedGameSystemWarFoundryLoader(system); |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
438 WarFoundryLoader.SetDefault(fixedLoader); |
04d7cd276b1d
Re #274: crash when missing unitMember id
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
439 } |
33
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
440 } |
03a8ab5e90d6
Re #236: Race loading should fail cleanly if system doesn't exist
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
441 } |