Mercurial > repos > IBBoard.WarFoundry.API.Tests
annotate API/Objects/Requirement/RequiresNUnitsForMUnitsRequirementTest.cs @ 191:2b19d6f18f3a
Re #350: Add requirement to allow N of unit for specific other units
* Correct expected output in tests - we haven't added when we check if adding is okay
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 03 Dec 2011 16:13:38 +0000 |
parents | 702a0957f9e4 |
children | f25cb069f700 |
rev | line source |
---|---|
188
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (UnitRequiresNUnitsForMUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
0762766bd3f2
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. |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 using System; |
0762766bd3f2
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; |
0762766bd3f2
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; |
0762766bd3f2
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; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using System.Reflection; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 using IBBoard.NUnit; |
0762766bd3f2
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; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 |
0762766bd3f2
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.Objects.Requirement |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 [TestFixture()] |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 public class RequiresNUnitsForMUnitsRequirementTest : AbstractEqualityTest<RequiresNUnitsForMUnitsRequirement> |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 private MockRace mockRace; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 private UnitType unitType1; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 private UnitType unitType2; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 private UnitType unitType3; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 [TestFixtureSetUp()] |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 public void SetupRace() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 mockRace = MockRace.GetMockRace(); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 unitType1 = new MockUnitType("type1", "Unit Type 1"); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 mockRace.AddUnitType(unitType1); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 unitType2 = new MockUnitType("type2", "Unit Type 2"); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 mockRace.AddUnitType(unitType2); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 unitType3 = new MockUnitType("type3", "Unit Type 3"); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 mockRace.AddUnitType(unitType3); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 [Test()] |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 public void TestAddingUnrelatedUnitWithNoUnitsAndOneUnitTypeRequiredIsNA() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 Army army = new Army(mockRace, "Test", 1000); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 Unit unit = CreateUnitOfType(unitType3, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.NotApplicable)); |
189
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
41 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty); |
188
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 [Test()] |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 public void TestAddingOneUnitWithOneUnitTypeRequiredAndOneUnitOfTypePasses() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 Army army = new Army(mockRace, "Test", 1000); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 AddUnitOfTypeToArmy(unitType2, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 Unit unit = CreateUnitOfType(unitType1, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed)); |
189
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
52 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty); |
188
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 [Test()] |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 public void TestAddingOneUnitWithOneUnitTypeRequiredAndNoUnitOfTypeFails() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 Army army = new Army(mockRace, "Test", 1000); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 Unit unit = CreateUnitOfType(unitType1, army); |
0762766bd3f2
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.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); |
191
2b19d6f18f3a
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
190
diff
changeset
|
62 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 "+unitType2.Name+" for every 1 "+unitType1.Name + " (would have 0 for 1).")); |
188
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 [Test()] |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 public void TestAddingTwoUnitsWithOneUnitTypeRequiredAndOneUnitOfTypeFails() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 Army army = new Army(mockRace, "Test", 1000); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 AddUnitOfTypeToArmy(unitType2, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 AddUnitOfTypeToArmy(unitType1, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 Unit unit = CreateUnitOfType(unitType1, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); |
191
2b19d6f18f3a
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
190
diff
changeset
|
74 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (would have 1 for 2).")); |
188
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 [Test()] |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 public void TestAddingTwoUnitsWithTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypePasses() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 Army army = new Army(mockRace, "Test", 1000); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 AddUnitOfTypeToArmy(unitType2, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 AddUnitOfTypeToArmy(unitType1, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 req.AddUnitTypeRequirement(unitType2, 1, 2); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 Unit unit = CreateUnitOfType(unitType1, army); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed)); |
189
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
87 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.Empty); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
88 } |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
89 |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
90 [Test()] |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
91 public void TestAddingThreeUnitsWithTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypeFails() |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
92 { |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
93 Army army = new Army(mockRace, "Test", 1000); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
94 AddUnitOfTypeToArmy(unitType2, army); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
95 AddUnitOfTypeToArmy(unitType1, army); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
96 AddUnitOfTypeToArmy(unitType1, army); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
97 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
98 req.AddUnitTypeRequirement(unitType2, 1, 2); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
99 Unit unit = CreateUnitOfType(unitType1, army); |
eea440e5891b
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
188
diff
changeset
|
100 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Failed)); |
191
2b19d6f18f3a
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
190
diff
changeset
|
101 Assert.That(req.GetAllowsAddingMessage(unit.UnitType, army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 2 " + unitType1.Name + " (would have 1 for 3).")); |
188
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 |
190
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
104 [Test()] |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
105 public void TestValidatingArmyWithNoUnitsAndOneUnitTypeRequiredIsNA() |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
106 { |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
107 Army army = new Army(mockRace, "Test", 1000); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
108 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
109 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.NotApplicable)); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
110 Assert.That(req.GetValidationMessage(army), Is.Empty); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
111 } |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
112 |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
113 [Test()] |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
114 public void TestValidatingArmyWithOneUnitTypeRequiredAndOneUnitOfTypePasses() |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
115 { |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
116 Army army = new Army(mockRace, "Test", 1000); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
117 AddUnitOfTypeToArmy(unitType2, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
118 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
119 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
120 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed)); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
121 Assert.That(req.GetValidationMessage(army), Is.Empty); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
122 } |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
123 |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
124 [Test()] |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
125 public void TestValidatingArmyWithOneUnitTypeRequiredAndNoUnitOfTypeFails() |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
126 { |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
127 Army army = new Army(mockRace, "Test", 1000); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
128 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
129 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
130 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
131 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 0 for 1).")); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
132 } |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
133 |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
134 [Test()] |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
135 public void TestValidatingArmyWithTwoUnitsAndOneUnitTypeRequiredAndOneUnitOfTypeFails() |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
136 { |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
137 Army army = new Army(mockRace, "Test", 1000); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
138 AddUnitOfTypeToArmy(unitType2, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
139 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
140 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
141 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1, unitType2); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
142 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
143 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 1 " + unitType1.Name + " (have 1 for 2).")); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
144 } |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
145 |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
146 [Test()] |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
147 public void TestValidatingArmyWithTwoUnitsAndTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypePasses() |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
148 { |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
149 Army army = new Army(mockRace, "Test", 1000); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
150 AddUnitOfTypeToArmy(unitType2, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
151 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
152 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
153 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
154 req.AddUnitTypeRequirement(unitType2, 1, 2); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
155 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed)); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
156 Assert.That(req.GetValidationMessage(army), Is.Empty); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
157 } |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
158 |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
159 [Test()] |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
160 public void TestValidatingArmyWithThreeUnitsAndTwoOfUnitTypeAllowedForOneUnitTypeRequiredAndOneUnitOfTypeFails() |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
161 { |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
162 Army army = new Army(mockRace, "Test", 1000); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
163 AddUnitOfTypeToArmy(unitType2, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
164 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
165 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
166 AddUnitOfTypeToArmy(unitType1, army); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
167 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType1); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
168 req.AddUnitTypeRequirement(unitType2, 1, 2); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
169 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
170 Assert.That(req.GetValidationMessage(army), Is.EqualTo("Army must contain: 1 " + unitType2.Name + " for every 2 " + unitType1.Name + " (have 1 for 3).")); |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
171 } |
702a0957f9e4
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
189
diff
changeset
|
172 |
188
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 private static void AddUnitOfTypeToArmy(UnitType unitType, Army army) |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 army.AddUnit(CreateUnitOfType(unitType, army)); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 private static Unit CreateUnitOfType(UnitType unitType, Army army) |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 return new Unit(unitType, army.GetCategory(unitType.MainCategory)); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
182 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 public override RequiresNUnitsForMUnitsRequirement GetObject() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
184 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
185 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
186 req.AddUnitTypeRequirement(unitType1, 2, 3); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 return req; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
188 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
189 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 public override RequiresNUnitsForMUnitsRequirement GetSameObject() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
193 req.AddUnitTypeRequirement(unitType1, 2, 3); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 return req; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
195 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
196 |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 public override RequiresNUnitsForMUnitsRequirement GetDifferentObject() |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
198 { |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
199 RequiresNUnitsForMUnitsRequirement req = new RequiresNUnitsForMUnitsRequirement(unitType3); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
200 DummyWarFoundryFactory factory = new DummyWarFoundryFactory(); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 GameSystem gameSystem = new GameSystem("system", "system", factory); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 Race race = new Race("race", "race", gameSystem, factory); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
203 req.AddUnitTypeRequirement(new UnitType("id2", "Type 2", race), 2, 3); |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 return req; |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
205 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
207 } |
0762766bd3f2
Re #350: Add requirement to allow N of unit for specific other units
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
208 |