annotate API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirementTest.cs @ 205:d39682a98adf

Re #379: Fix validation of requirements to check for unit * Add unit tests for army object * Update tests that check the message
author IBBoard <dev@ibboard.co.uk>
date Sun, 29 Jan 2012 19:40:19 +0000
parents 8c519a44e699
children 27f163bf884a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
132
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
1 // This file (UnitRequiresAtLeastNUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
2 //
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
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.
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
4 using System;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
5 using NUnit.Framework;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
8
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects.Requirement
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
10 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
11 [TestFixture()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
12 public class UnitRequiresAtLeastNUnitsRequirementTest
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
13 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
14 private MockRace mockRace;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
15 private UnitType unitType1;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
16 private UnitType unitType2;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
17 private UnitType unitType3;
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
18
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
19 [TestFixtureSetUp()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
20 public void SetupRace()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
21 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
22 mockRace = new MockRace();
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
23 unitType1 = new MockUnitType("type1", "Unit Type 1");
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
24 mockRace.AddUnitType(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
25 unitType2 = new MockUnitType("type2", "Unit Type 2");
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
26 mockRace.AddUnitType(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
27 unitType3 = new MockUnitType("type3", "Unit Type 3");
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
28 mockRace.AddUnitType(unitType3);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
29 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
30
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
31 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
32 public void TestAddingUnitWithNoUnitsAndOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
33 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
34 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
35 Unit unit = CreateUnitOfType(unitType1, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
36 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
37 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
38 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
39 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
40
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
41 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
42 public void TestAddingUnitWithOneUnitAndOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
43 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
44 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
45 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
46 Unit unit = CreateUnitOfType(unitType1, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
47 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
48 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
49 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
50 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
51
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
52 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
53 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
54 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
55 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
56 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
57 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
58 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
59 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
60
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
61 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
62 public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
63 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
64 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
65 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
66 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
67 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
68 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
69 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
70
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
71 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
72 public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
73 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
74 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
75 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
76 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
77 req.AddUnitTypeRequirement(unitType3);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
78 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
79 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
80
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
81 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
82 public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
83 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
84 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
85 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
86 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
87 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
88 req.AddUnitTypeRequirement(unitType3);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
89 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
90 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
91
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
92 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
93 public void TestAddingUnitTypeWithOtherOneUnitAndTwoUnitTypesRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
94 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
95 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
96 AddUnitOfTypeToArmy(unitType3, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
97 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
98 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
99 req.AddUnitTypeRequirement(unitType3);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
100 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
101 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
102
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
103 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
104 public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
105 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
106 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
107 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
108 AddUnitOfTypeToArmy(unitType3, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
109 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
110 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
111 req.AddUnitTypeRequirement(unitType3);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
112 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
113 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
114
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
115 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
116 public void TestAddingUnitTypeWithOneUnitAndTwoOfOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
117 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
118 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
119 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
120 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
121 req.AddUnitTypeRequirement(unitType2, 2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
122 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
123 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
124
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
125 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
126 public void TestAddingUnrelatedUnitTypeIsAllowedWhenRequirementsNotMet()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
127 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
128 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
129 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
130 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
131 req.AddUnitTypeRequirement(unitType2, 2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
132 Assert.That(req.AllowsAdding(unitType3, army), Is.EqualTo(Validation.NotApplicable));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
133 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
134
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
135 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
136 public void TestAddingUnitTypeWithTwoUnitsAndTwoOfOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
137 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
138 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
139 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
140 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
141 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
142 req.AddUnitTypeRequirement(unitType2, 2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
143 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
144 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
145
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
146 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
147 public void TestAddingUnitTypeRequirementWithNoNumberDefaultsToHavingOne()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
148 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
149 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
150 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
151 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
152 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
153 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
154 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
155
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
156 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
157 public void TestAddingUnitTypeMakesRequirementPass()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
158 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
159 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
160 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
161 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
162 req.AddUnitTypeRequirement(unitType2, 2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
163 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
164 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
165 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
166 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
167
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
168 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
169 public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
170 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
171 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
172 AddUnitOfTypeToArmy(unitType1, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
173 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
174 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
175 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
176 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
177
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
178 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
179 public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
180 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
181 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
182 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
183 AddUnitOfTypeToArmy(unitType1, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
184 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
185 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
186 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
187 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
188
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
189 [Test()]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
190 public void TestValidityOfArmyWhenNoRequireeAndRequirementNotMet()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
191 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
192 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
193 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
194 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
195 req.AddUnitTypeRequirement(unitType2, 2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
196 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
197 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
198
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
199 [Test]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
200 public void TestSatisfyingRequirementChangesResult()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
201 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
202 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
203 AddUnitOfTypeToArmy(unitType1, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
204 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
205 req.AddUnitTypeRequirement(unitType2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
206 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
207 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
208 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
209 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
210
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
211 [Test]
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
212 public void TestAddingMinNumberUnitTypePassesRequirement()
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
213 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
214 Army army = new Army(mockRace, "Test", 1000);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
215 AddUnitOfTypeToArmy(unitType1, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
216 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
217 req.AddUnitTypeRequirement(unitType2, 2);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
218 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
219 AddUnitOfTypeToArmy(unitType2, army);
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
220 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
221 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
222
142
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
223 [Test]
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
224 public void TestValidationMessageIsBlankForPass()
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
225 {
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
226 Army army = new Army(mockRace, "Test", 1000);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
227 AddUnitOfTypeToArmy(unitType1, army);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
228 AddUnitOfTypeToArmy(unitType2, army);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
229 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
230 req.AddUnitTypeRequirement(unitType2);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
231 Assert.That(req.GetValidationMessage(army), Is.Empty);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
232 }
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
233
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
234 [Test]
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
235 public void TestValidationMessageIsCorrectForFailWithOneUnitRequired()
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
236 {
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
237 Army army = new Army(mockRace, "Test", 1000);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
238 AddUnitOfTypeToArmy(unitType1, army);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
239 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
240 req.AddUnitTypeRequirement(unitType2);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
241 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so must contain: 1 × " + unitType2.Name + " (have 0)."));
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
242 }
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
243
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
244 [Test]
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
245 public void TestValidationMessageIsCorrectForFailWithTwoOfOneUnitRequired()
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
246 {
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
247 Army army = new Army(mockRace, "Test", 1000);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
248 AddUnitOfTypeToArmy(unitType1, army);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
249 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
250 req.AddUnitTypeRequirement(unitType2, 2);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
251 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so must contain: 2 × " + unitType2.Name + " (have 0)."));
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
252 }
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
253
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
254 [Test]
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
255 public void TestValidationMessageIsCorrectForFailWithTwoUnitsRequired()
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
256 {
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
257 Army army = new Army(mockRace, "Test", 1000);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
258 AddUnitOfTypeToArmy(unitType1, army);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
259 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
260 req.AddUnitTypeRequirement(unitType2);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
261 req.AddUnitTypeRequirement(unitType3);
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
262 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army contains " + unitType1.Name + " and so must contain: 1 × " + unitType2.Name + " (have 0); 1 × " + unitType3.Name + " (have 0)."));
f36b5e5e51e6 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 132
diff changeset
263 }
132
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
264
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
265 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
266 public void TestAllowsAddingMessageIsBlankForPass()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
267 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
268 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
269 AddUnitOfTypeToArmy(unitType1, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
270 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
271 Assert.That(req.GetAllowsAddingMessage(unitType1, army), Is.Empty);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
272 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
273
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
274 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
275 public void TestAllowsAddingMessageIsCorrectForFailWithTwoOfOneUnitRequired()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
276 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
277 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
278 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
279 req.AddUnitTypeRequirement(unitType2, 2);
205
d39682a98adf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 146
diff changeset
280 Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army would contain " + unitType1.Name + " and so must contain: 2 × " + unitType2.Name + " (would have 1)."));
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
281 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
282
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
283 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
284 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequired()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
285 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
286 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
287 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
288 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
289 req.AddUnitTypeRequirement(unitType3);
205
d39682a98adf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 146
diff changeset
290 Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army would contain " + unitType1.Name + " and so must contain: 1 × " + unitType3.Name + " (would have 0)."));
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
291 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
292
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
293 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
294 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
295 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
296 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
297 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
298 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
299 req.AddUnitTypeRequirement(unitType3);
205
d39682a98adf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 146
diff changeset
300 Assert.That(req.GetAllowsAddingMessage(unitType3, army), Is.EqualTo("Army would contain " + unitType1.Name + " and so must contain: 1 × " + unitType2.Name + " (would have 0)."));
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
301 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
302
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
303 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
304 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredWithOneUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
305 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
306 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
307 AddUnitOfTypeToArmy(unitType2, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
308 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
309 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
310 req.AddUnitTypeRequirement(unitType3);
205
d39682a98adf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 146
diff changeset
311 Assert.That(req.GetAllowsAddingMessage(unitType2, army), Is.EqualTo("Army would contain " + unitType1.Name + " and so must contain: 1 × " + unitType3.Name + " (would have 0)."));
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
312 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
313
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
314 [Test]
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
315 public void TestAllowsAddingMessageIsCorrectForFailWithTwoUnitsRequiredWithOtherUnit()
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
316 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
317 Army army = new Army(mockRace, "Test", 1000);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
318 AddUnitOfTypeToArmy(unitType3, army);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
319 RequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType1);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
320 req.AddUnitTypeRequirement(unitType2);
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
321 req.AddUnitTypeRequirement(unitType3);
205
d39682a98adf Re #379: Fix validation of requirements to check for unit
IBBoard <dev@ibboard.co.uk>
parents: 146
diff changeset
322 Assert.That(req.GetAllowsAddingMessage(unitType3, army), Is.EqualTo("Army would contain " + unitType1.Name + " and so must contain: 1 × " + unitType2.Name + " (would have 0)."));
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
323 }
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 142
diff changeset
324
132
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
325 private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
326 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
327 army.AddUnit(CreateUnitOfType(unitType, army));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
328 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
329
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
330 private static Unit CreateUnitOfType(UnitType unitType, Army army)
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
331 {
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
332 return new Unit(unitType, army.GetCategory(unitType.MainCategory));
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
333 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
334 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
335 }
8f1af48e120c Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 125
diff changeset
336