Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
annotate API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs @ 155:3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
* Add mock factory and use it in tests
All tests now pass (including tests that started failing because of unit loading order - triggered by requirement changes)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 04 Jul 2011 20:03:47 +0000 |
parents | bf2880cf7bc5 |
children | 17c5030485dc |
rev | line source |
---|---|
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
b86955aa252c
Re #351: Add extensible requirement handling method
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. |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 using System; |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using NUnit.Framework; |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using IBBoard.WarFoundry.API.Objects.Mock; |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using NUnit.Framework.SyntaxHelpers; |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using IBBoard.WarFoundry.API.Objects; |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 using IBBoard.WarFoundry.API.Objects.Requirement; |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
10 using IBBoard.WarFoundry.API.Factories.Mock; |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 namespace IBBoard.WarFoundry.API.Factories.Requirement |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 { |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 [TestFixture()] |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 public class UnitRequiresAtLeastNUnitsRequirementFactoryTest |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 { |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 private static Race race; |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
18 private static string typeID1 = "unit1"; |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
19 private static string typeID2 = "unit2"; |
153
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
20 private static UnitType unitType1; |
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
21 private static UnitType unitType2; |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
22 private static MockRaceFactory raceFactory = new MockRaceFactory(); |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 [TestFixtureSetUp()] |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 public void Setup() |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 { |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 race = new MockRace(); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
28 unitType1 = new UnitType(typeID1, "Unit 1", race); |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 race.AddUnitType(unitType1); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
30 unitType2 = new UnitType(typeID2, "Unit 2", race); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
31 race.AddUnitType(unitType2); |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 } |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 [Test()] |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 public void TestCreatesRequirement() |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 { |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
38 Assert.That(factory.CreateRequirement(unitType2, typeID1, raceFactory), Is.Not.Null); |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 } |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 [Test()] |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 public void TestCreatesCorrectRequirement() |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 { |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
45 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
46 UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
47 expectedReq.AddUnitTypeRequirement(unitType1); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
48 UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID1, raceFactory); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
49 Assert.That(req, Is.EqualTo(expectedReq)); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
50 } |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
51 |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
52 [Test()] |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
53 public void TestCreatesCorrectRequirementForTwoIDs() |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
54 { |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
55 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
56 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 expectedReq.AddUnitTypeRequirement(unitType1); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
59 expectedReq.AddUnitTypeRequirement(unitType2); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
60 UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID1 + "|" + typeID2, raceFactory); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
61 Assert.That(req, Is.EqualTo(expectedReq)); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
62 } |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
63 |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
64 [Test()] |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
65 public void TestCreatesCorrectRequirementWithNumber() |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
66 { |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
67 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
68 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
69 UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
70 expectedReq.AddUnitTypeRequirement(unitType1, 2); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
71 UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2", raceFactory); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
72 Assert.That(req, Is.EqualTo(expectedReq)); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
73 } |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
74 |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
75 [Test()] |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
76 public void TestCreatesCorrectRequirementForTwoIDsWithTwoNumbers() |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
77 { |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
78 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
79 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
80 UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
81 expectedReq.AddUnitTypeRequirement(unitType1, 2); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
82 expectedReq.AddUnitTypeRequirement(unitType2, 3); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
83 UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2|" + typeID2 + ":3", raceFactory); |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 Assert.That(req, Is.EqualTo(expectedReq)); |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 } |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
86 |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
87 [Test()] |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
88 public void TestCreatesCorrectRequirementForTwoIDsWithOneNumber() |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
89 { |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
90 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
91 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
92 UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
93 expectedReq.AddUnitTypeRequirement(unitType1, 2); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
94 expectedReq.AddUnitTypeRequirement(unitType2); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
95 UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2|" + typeID2, raceFactory); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
96 Assert.That(req, Is.EqualTo(expectedReq)); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
97 } |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
98 |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
99 [Test()] |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
100 public void TestCreatesCorrectRequirementForTwoIDsWithOtherNumber() |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
101 { |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
102 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
103 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
104 UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
105 expectedReq.AddUnitTypeRequirement(unitType1); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
106 expectedReq.AddUnitTypeRequirement(unitType2, 3); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
107 UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID1 + "|" + typeID2 + ":3", raceFactory); |
151
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
108 Assert.That(req, Is.EqualTo(expectedReq)); |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
109 } |
60de02ce78d8
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
110 |
152
dd283afa5971
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
151
diff
changeset
|
111 [Test()] |
154 | 112 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid unit type 'fibble' for 'Requires at least N units' requirement")] |
153
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
113 public void TestExceptionsForInvalidID() |
152
dd283afa5971
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
151
diff
changeset
|
114 { |
dd283afa5971
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
151
diff
changeset
|
115 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
dd283afa5971
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
151
diff
changeset
|
116 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
117 factory.CreateRequirement(unitType, "fibble", raceFactory); |
152
dd283afa5971
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
151
diff
changeset
|
118 } |
153
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
119 |
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
120 [Test()] |
154 | 121 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid amount 'a' for unit type 'unit1' for 'Requires at least N units' requirement")] |
153
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
122 public void TestExceptionsForInvalidNumber() |
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
123 { |
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
124 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory(); |
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
125 UnitType unitType = new UnitType("testUnit", "Test Unit", race); |
155
3725fd449c77
Re #353: Handle unloaded units being referenced outside factory
IBBoard <dev@ibboard.co.uk>
parents:
154
diff
changeset
|
126 factory.CreateRequirement(unitType, typeID1+":a", raceFactory); |
153
e84149f37478
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
152
diff
changeset
|
127 } |
150
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 } |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 } |
b86955aa252c
Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 |