annotate API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactoryTest.cs @ 200:6a0a0e228e3c

Re #350: Add requirement to allow N of unit for specific other units * Add unit tests for additive requirements Still need tests to make sure mixing additive with non-additive is handled correctly
author IBBoard <dev@ibboard.co.uk>
date Tue, 20 Dec 2011 21:01:46 +0000
parents f1f4df654a91
children 43b571aa4124
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
193
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitUnitRequiresNUnitsForMUnitsRequirementFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
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.
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Objects;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API.Objects.Requirement;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 using IBBoard.WarFoundry.API.Factories.Mock;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 namespace IBBoard.WarFoundry.API.Factories.Requirement
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [TestFixture()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 public class UnitUnitRequiresNUnitsForMUnitsRequirementFactoryTest
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 private static Race race;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 private static string typeID1 = "unit1";
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 private static string typeID2 = "unit2";
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 private static UnitType unitType1;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 private static UnitType unitType2;
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 private static MockRaceFactory raceFactory = new MockRaceFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 [TestFixtureSetUp()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 public void Setup()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 race = new MockRace();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 unitType1 = new UnitType(typeID1, "Unit 1", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 race.AddUnitType(unitType1);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 unitType2 = new UnitType(typeID2, "Unit 2", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 race.AddUnitType(unitType2);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 [Test()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 public void TestCreatesRequirement()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 Assert.That(factory.CreateRequirement(unitType2, typeID1, raceFactory), Is.Not.Null);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 [Test()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 public void TestCreatesCorrectRequirement()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 expectedReq.AddUnitTypeRequirement(unitType1);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 IRequirement req = factory.CreateRequirement(unitType, typeID1, raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 Assert.That(req, Is.EqualTo(expectedReq));
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 [Test()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 public void TestCreatesCorrectRequirementForTwoIDs()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 expectedReq.AddUnitTypeRequirement(unitType1);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 expectedReq.AddUnitTypeRequirement(unitType2);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 IRequirement req = factory.CreateRequirement(unitType, typeID1 + "|" + typeID2, raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 Assert.That(req, Is.EqualTo(expectedReq));
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 [Test()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 public void TestCreatesCorrectRequirementWithNumber()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 expectedReq.AddUnitTypeRequirement(unitType1, 2);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2", raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 Assert.That(req, Is.EqualTo(expectedReq));
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 [Test()]
194
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
76 public void TestCreatesCorrectRequirementWithTwoNumbers()
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
77 {
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
78 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
79 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
80 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
81 expectedReq.AddUnitTypeRequirement(unitType1, 2, 3);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
82 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2;3", raceFactory);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
83 Assert.That(req, Is.EqualTo(expectedReq));
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
84 }
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
85
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
86 [Test()]
193
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 public void TestCreatesCorrectRequirementForTwoIDsWithTwoNumbers()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 expectedReq.AddUnitTypeRequirement(unitType1, 2);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 expectedReq.AddUnitTypeRequirement(unitType2, 3);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2|" + typeID2 + ":3", raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 Assert.That(req, Is.EqualTo(expectedReq));
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 [Test()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 public void TestCreatesCorrectRequirementForTwoIDsWithOneNumber()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 expectedReq.AddUnitTypeRequirement(unitType1, 2);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 expectedReq.AddUnitTypeRequirement(unitType2);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ":2|" + typeID2, raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 Assert.That(req, Is.EqualTo(expectedReq));
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 [Test()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 public void TestCreatesCorrectRequirementForTwoIDsWithOtherNumber()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 expectedReq.AddUnitTypeRequirement(unitType1);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 expectedReq.AddUnitTypeRequirement(unitType2, 3);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 IRequirement req = factory.CreateRequirement(unitType, typeID1 + "|" + typeID2 + ":3", raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 Assert.That(req, Is.EqualTo(expectedReq));
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 [Test()]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid unit type 'fibble' for 'Requires N units for M units' requirement")]
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 public void TestExceptionsForInvalidID()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 factory.CreateRequirement(unitType, "fibble", raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 [Test()]
200
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
132 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit types 'unit1' for 'Requires N units for M units' requirement")]
193
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 public void TestExceptionsForInvalidNumber()
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 {
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 factory.CreateRequirement(unitType, typeID1+":a", raceFactory);
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 }
194
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
139
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
140 [Test()]
200
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
141 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit types 'unit1' for 'Requires N units for M units' requirement")]
194
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
142 public void TestExceptionsForInvalidAllowedNumber()
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
143 {
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
144 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
145 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
146 factory.CreateRequirement(unitType, typeID1 + ":3;a", raceFactory);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
147 }
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
148
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
149 [Test()]
200
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
150 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid minimum amount 'a' for unit types 'unit1' for 'Requires N units for M units' requirement")]
194
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
151 public void TestExceptionsForInvalidMinimumNumber()
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
152 {
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
153 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
154 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
155 factory.CreateRequirement(unitType, typeID1 + ":a;3", raceFactory);
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
156 }
200
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
157
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
158 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
159 public void TestCreatesCorrectAdditiveRequirement()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
160 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
161 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
162 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
163 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
164 expectedReq.AddUnitTypeRequirement(unitType1, unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
165 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ";" + typeID2, raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
166 Assert.That(req, Is.EqualTo(expectedReq));
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
167 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
168
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
169 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
170 public void TestCreatesCorrectAdditiveRequirementForTwoIDs()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
171 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
172 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
173 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
174 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
175 expectedReq.AddUnitTypeRequirement(unitType1, unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
176 expectedReq.AddUnitTypeRequirement(unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
177 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + "|" + typeID2, raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
178 Assert.That(req, Is.EqualTo(expectedReq));
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
179 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
180
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
181 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
182 public void TestCreatesCorrectAdditiveRequirementWithNumber()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
183 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
184 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
185 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
186 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
187 expectedReq.AddUnitTypeRequirement(2, unitType1, unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
188 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + ":2", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
189 Assert.That(req, Is.EqualTo(expectedReq));
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
190 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
191
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
192 /*[Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
193 public void TestCreatesCorrectAdditiveRequirementWithTwoNumbers()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
194 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
195 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
196 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
197 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
198 expectedReq.AddUnitTypeRequirement(2, 3, unitType1, unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
199 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + ":2;3", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
200 Assert.That(req, Is.EqualTo(expectedReq));
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
201 }*/
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
202
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
203 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
204 public void TestCreatesCorrectAdditiveRequirementForTwoIDsWithTwoNumbers()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
205 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
206 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
207 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
208 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
209 expectedReq.AddUnitTypeRequirement(2, unitType1, unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
210 expectedReq.AddUnitTypeRequirement(3, unitType2, unitType1);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
211 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + ":2|" + typeID2 + ";" + typeID1 + ":3", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
212 Assert.That(req, Is.EqualTo(expectedReq));
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
213 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
214
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
215 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
216 public void TestCreatesCorrectAdditiveRequirementForTwoIDsWithOneNumber()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
217 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
218 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
219 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
220 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
221 expectedReq.AddUnitTypeRequirement(2, unitType1, unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
222 expectedReq.AddUnitTypeRequirement(unitType2, unitType1);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
223 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + ":2|" + typeID2 + ";" + typeID1, raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
224 Assert.That(req, Is.EqualTo(expectedReq));
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
225 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
226
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
227 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
228 public void TestCreatesCorrectAdditiveRequirementForTwoIDsWithOtherNumber()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
229 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
230 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
231 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
232 RequiresNUnitsForMUnitsRequirement expectedReq = new RequiresNUnitsForMUnitsRequirement(unitType);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
233 expectedReq.AddUnitTypeRequirement(unitType1, unitType2);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
234 expectedReq.AddUnitTypeRequirement(3, unitType2, unitType1);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
235 IRequirement req = factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + "|" + typeID2 + ";" + typeID1 + ":3", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
236 Assert.That(req, Is.EqualTo(expectedReq));
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
237 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
238
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
239 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
240 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid unit type 'fibble' for 'Requires N units for M units' requirement")]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
241 public void TestExceptionsForAdditiveRequirementWithInvalidID()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
242 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
243 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
244 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
245 factory.CreateRequirement(unitType, "fibble;" + typeID1, raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
246 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
247
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
248 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
249 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid unit type 'fibble' for 'Requires N units for M units' requirement")]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
250 public void TestExceptionsForAdditiveRequirementWithOtherInvalidID()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
251 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
252 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
253 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
254 factory.CreateRequirement(unitType, typeID1 + ";fibble", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
255 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
256
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
257 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
258 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit types 'unit1;unit2' for 'Requires N units for M units' requirement")]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
259 public void TestExceptionsForAdditiveRequirementWithInvalidNumber()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
260 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
261 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
262 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
263 factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + ":a", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
264 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
265
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
266 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
267 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit types 'unit1;unit2' for 'Requires N units for M units' requirement")]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
268 public void TestExceptionsForAdditiveRequirementWithInvalidAllowedNumber()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
269 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
270 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
271 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
272 factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + ":3;a", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
273 }
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
274
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
275 [Test()]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
276 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid minimum amount 'a' for unit types 'unit1;unit2' for 'Requires N units for M units' requirement")]
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
277 public void TestExceptionsForAdditiveRequirementWithInvalidMinimumNumber()
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
278 {
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
279 UnitRequiresNUnitsForMUnitsRequirementFactory factory = new UnitRequiresNUnitsForMUnitsRequirementFactory();
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
280 UnitType unitType = new UnitType("testUnit", "Test Unit", race);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
281 factory.CreateRequirement(unitType, typeID1 + ";" + typeID2 + ":a;3", raceFactory);
6a0a0e228e3c Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 194
diff changeset
282 }
193
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
283 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
284 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
285