annotate API/Factories/Requirement/UnitRequiresNUnitsForMUnitsRequirementFactoryTest.cs @ 194:f1f4df654a91

Re #350: Add requirement to allow N of unit for specific other units * Add tests for defining minimum amount as well as allowed amount (e.g. "2 of these allow 3 of those")
author IBBoard <dev@ibboard.co.uk>
date Sat, 03 Dec 2011 19:56:58 +0000
parents cf1c0a91eaa9
children 6a0a0e228e3c
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()]
194
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
132 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit type '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()]
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
141 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid allowed amount 'a' for unit type 'unit1' for 'Requires N units for M units' requirement")]
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()]
f1f4df654a91 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
150 [ExpectedException(typeof(InvalidRequirementException), ExpectedMessage="Invalid minimum amount 'a' for unit type 'unit1' for 'Requires N units for M units' requirement")]
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 }
193
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 }
cf1c0a91eaa9 Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159