Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
comparison API/Factories/Xml/WarFoundryXmlRaceFactoryTest.cs @ 62:ef8950a5f4cb
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
* Test duplicate member type keys
* Test valid case of member type key with reference
* Move existing "non-existant member type" data to sub-folder and rename
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 19 Jun 2010 19:30:58 +0000 |
parents | 27625216d8d6 |
children | a9163f8dfba1 |
comparison
equal
deleted
inserted
replaced
61:27625216d8d6 | 62:ef8950a5f4cb |
---|---|
43 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); | 43 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 [Test()] | 47 [Test()] |
48 public void TestCompleteLoadingOnRaceWithDuplicateAbilityIdErrors() | |
49 { | |
50 SetDefaultGameSystem(); | |
51 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/duplicate-ability.racex"); | |
52 | |
53 try | |
54 { | |
55 SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); | |
56 Assert.Fail("Excepted exception not thrown"); | |
57 } | |
58 catch (InvalidFileException ex) | |
59 { | |
60 Console.WriteLine(ex.Message); | |
61 Exception innerException = ex.InnerException; | |
62 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); | |
63 } | |
64 } | |
65 | |
66 [Test()] | |
48 public void TestCompleteLoadingOnRaceWithAbilityLoadsData() | 67 public void TestCompleteLoadingOnRaceWithAbilityLoadsData() |
49 { | 68 { |
50 SetDefaultGameSystem(); | 69 SetDefaultGameSystem(); |
51 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-ability.racex"); | 70 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-ability.racex"); |
52 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); | 71 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
53 UnitType unitType = race.GetUnitType("Empire1"); | 72 UnitType unitType = race.GetUnitType("Empire1"); |
54 Ability ability = race.GetAbility("leaderOfMen"); | 73 Ability ability = race.GetAbility("leaderOfMen"); |
55 Assert.That(ability.Name, Is.EqualTo("Leader of Men")); | 74 Assert.That(ability.Name, Is.EqualTo("Leader of Men")); |
56 Assert.That(ability.Description, Is.EqualTo("All men will follow the character and can use his leadership")); | 75 Assert.That(ability.Description, Is.EqualTo("All men will follow the character and can use his leadership")); |
57 Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability)); | 76 Assert.That(unitType.GetRequiredAbilities(), Has.Member(ability)); |
58 | 77 } |
59 } | 78 |
60 | 79 [Test()] |
61 [Test()] | 80 public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDErrors() |
62 public void TestCompleteLoadingOnRaceWithIncorrectMemberTypeIDError() | 81 { |
63 { | 82 SetDefaultGameSystem(); |
64 SetDefaultGameSystem(); | 83 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/non-existant-member-type.racex"); |
65 FileInfo raceFile = new FileInfo("testdata/single-unit-non-existant-type-referencing-race.racex"); | |
66 | 84 |
67 try | 85 try |
68 { | 86 { |
69 SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); | 87 SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); |
70 Assert.Fail("Excepted exception not thrown"); | 88 Assert.Fail("Excepted exception not thrown"); |
73 { | 91 { |
74 Console.WriteLine(ex.Message); | 92 Console.WriteLine(ex.Message); |
75 Exception innerException = ex.InnerException; | 93 Exception innerException = ex.InnerException; |
76 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); | 94 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); |
77 } | 95 } |
96 } | |
97 | |
98 [Test()] | |
99 public void TestCompleteLoadingOnRaceWithDuplicateMemberTypeIDErrors() | |
100 { | |
101 SetDefaultGameSystem(); | |
102 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/duplicate-member-type.racex"); | |
103 | |
104 try | |
105 { | |
106 SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); | |
107 Assert.Fail("Excepted exception not thrown"); | |
108 } | |
109 catch (InvalidFileException ex) | |
110 { | |
111 Console.WriteLine(ex.Message); | |
112 Exception innerException = ex.InnerException; | |
113 Assert.That(innerException, Is.InstanceOfType(typeof(XmlSchemaValidationException))); | |
114 } | |
115 } | |
116 | |
117 [Test()] | |
118 public void TestCompleteLoadingOnRaceWithMemberTypeLoadsData() | |
119 { | |
120 SetDefaultGameSystem(); | |
121 FileInfo raceFile = new FileInfo("testdata/xml-race-factory/existing-member-type.racex"); | |
122 Race race = SingleXmlObjectLoader.LoadRaceFromXML(WarFoundryXmlFactory.GetFactory(), raceFile); | |
123 UnitMemberType memberType = race.GetUnitMemberType("General"); | |
124 Assert.That(memberType.Name, Is.EqualTo("General")); | |
78 } | 125 } |
79 | 126 |
80 [Test()] | 127 [Test()] |
81 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors() | 128 public void TestCompleteLoadingOnRaceWithIncorrectEquipmentSlotErrors() |
82 { | 129 { |