annotate API/Objects/Requirement/RequiresAtLeastNUnitsRequirementTest.cs @ 138:11faab6c712a

Re #140: Add equality methods * Add equality method tests for RequiresAtLeastNUnitsRequirement
author IBBoard <dev@ibboard.co.uk>
date Tue, 26 Apr 2011 19:14:34 +0000
parents 7fa4d5215afe
children 2ae80631ec9c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
1 // This file (UnitRequiresAtLeastNUnitsRequirement.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
a3bc8174299f Re #27: Define unit requirements
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.
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
5 using NUnit.Framework;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
8 using System.Reflection;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
9 using IBBoard.NUnit;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
10 using IBBoard.WarFoundry.API.Factories;
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
12 namespace IBBoard.WarFoundry.API.Objects.Requirement
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [TestFixture()]
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
15 public class RequiresAtLeastNUnitsRequirementTest : AbstractEqualityTest<RequiresAtLeastNUnitsRequirement>
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
16 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
17 //FIXME We shouldn't duplicate these tests, but it is broken at the moment
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
18 [Test]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
19 public void TestEquality()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
20 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
21 Assert.AreEqual(GetObject(), GetSameObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
22 Assert.AreEqual(GetSameObject(), GetObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
23 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
24
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
25 [Test]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
26 public void TestInequality()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
27 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
28 Assert.AreNotEqual(GetObject(), GetDifferentObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
29 Assert.AreNotEqual(GetSameObject(), GetDifferentObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
30 Assert.AreNotEqual(GetDifferentObject(), GetObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
31 Assert.AreNotEqual(GetDifferentObject(), GetSameObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
32 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
33
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
34 [Test]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
35 public void TestReflexiveEquality()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
36 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
37 Assert.AreEqual(GetObject(), GetObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
38 Assert.AreEqual(GetSameObject(), GetSameObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
39 Assert.AreEqual(GetDifferentObject(), GetDifferentObject());
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
40 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
41
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
42 [Test]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
43 public void TestOtherInequality()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
44 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
45 MethodInfo[] methodInfo = GetType().GetMethods();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
46 RequiresAtLeastNUnitsRequirement obj = GetObject();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
47
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
48 foreach (MethodInfo method in methodInfo)
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
49 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
50 if (method.Name.StartsWith("GetOtherDifferent"))
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
51 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
52 RequiresAtLeastNUnitsRequirement otherObj = (RequiresAtLeastNUnitsRequirement)method.Invoke(this, new object[0]);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
53 Assert.AreNotEqual(obj, otherObj, "Objects equal for "+method.Name);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
54 Assert.AreNotEqual(otherObj, obj, "Objects equal for "+method.Name);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
55 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
56 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
57 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
58
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
59
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
60
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
61
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
62 private MockRace mockRace;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
63 private UnitType unitType1;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
64 private UnitType unitType2;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
65 private UnitType unitType3;
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
66
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
67 [TestFixtureSetUp()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
68 public void SetupRace()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
69 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
70 mockRace = MockRace.GetMockRace();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
71 unitType1 = new MockUnitType("type1", "Unit Type 1");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
72 mockRace.AddUnitType(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
73 unitType2 = new MockUnitType("type2", "Unit Type 2");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
74 mockRace.AddUnitType(unitType2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
75 unitType3 = new MockUnitType("type3", "Unit Type 3");
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
76 mockRace.AddUnitType(unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
77 }
103
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
78
c6562eb62d04 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 102
diff changeset
79 [Test()]
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
80 public void TestAddingUnrelatedUnitWithNoUnitsAndOneUnitTypeRequired()
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
81 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
82 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
83 Unit unit = CreateUnitOfType(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
84 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
85 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.NotApplicable));
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
86 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
87
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
88 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
89 public void TestAddingOneUnitWithOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
90 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
91 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
92 Unit unit = CreateUnitOfType(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
93 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
94 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
95 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
96
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
97 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
98 public void TestAddingUnitWithOneUnitAndTwoOfUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
99 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
100 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
101 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
102 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
103 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
104 Unit unit = CreateUnitOfType(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
105 Assert.That(req.AllowsAdding(unit, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
106 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
107
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
108 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
109 public void TestAddingUnrelatedUnitTypeWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
110 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
111 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
112 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
113 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.NotApplicable));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
114 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
115
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
116 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
117 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
118 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
119 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
120 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
121 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
122 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
123
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
124 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
125 public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
126 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
127 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
128 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
129 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
130 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
131 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
132
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
133 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
134 public void TestAddingUnitTypeWithNoUnitsAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
135 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
136 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
137 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
138 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
139 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
140
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
141 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
142 public void TestAddingUnitTypeWithOneUnitAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
143 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
144 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
145 AddUnitOfTypeToArmy(unitType3, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
146 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
147 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
148 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
149
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
150 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
151 public void TestAddingUnitTypeWithBothUnitsAndTwoUnitTypesRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
152 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
153 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
154 AddUnitOfTypeToArmy(unitType2, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
155 AddUnitOfTypeToArmy(unitType3, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
156 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType2, unitType3);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
157 Assert.That(req.AllowsAdding(unitType2, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
158 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
159
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
160 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
161 public void TestAddingOneOfUnitTypeWithTwoOfOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
162 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
163 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
164 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
165 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
166 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
167 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
168
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
169 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
170 public void TestAddingOneUnitTypeWithOneUnitAndTwoOfOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
171 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
172 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
173 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
174 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
175 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
176 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
177 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
178
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
179 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
180 public void TestAddingUnitTypeRequirementWithNoNumberDefaultsToHavingOne()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
181 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
182 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
183 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
184 req.AddUnitTypeRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
185 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
186 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
187
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
188 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
189 public void TestValidityOfArmyWithNoUnitsAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
190 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
191 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
192 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
193 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
194 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
195
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
196 [Test()]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
197 public void TestValidityOfArmyWithOneUnitAndOneUnitTypeRequired()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
198 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
199 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
200 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
201 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement(unitType1);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
202 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
203 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
204
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
205 [Test]
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
206 public void TestAddingMinNumberUnitTypePassesRequirement()
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
207 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
208 Army army = new Army(mockRace, "Test", 1000);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
209 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
210 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
211 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Failed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
212 AddUnitOfTypeToArmy(unitType1, army);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
213 Assert.That(req.AllowsAdding(unitType1, army), Is.EqualTo(Validation.Passed));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
214 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
215
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
216 private static void AddUnitOfTypeToArmy(UnitType unitType, Army army)
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
217 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
218 army.AddUnit(CreateUnitOfType(unitType, army));
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
219 }
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
220
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
221 private static Unit CreateUnitOfType(UnitType unitType, Army army)
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
222 {
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
223 return new Unit(unitType, army.GetCategory(unitType.MainCategory));
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
224 }
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
225
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
226 public override RequiresAtLeastNUnitsRequirement GetObject ()
106
4dad874f4862 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
227 {
107
e2ea6562ef08 Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 106
diff changeset
228 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
130
7fa4d5215afe Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 124
diff changeset
229 req.AddUnitTypeRequirement(unitType1, 2);
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
230 return req;
110
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
231 }
788ef54f5b5a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 109
diff changeset
232
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
233 public override RequiresAtLeastNUnitsRequirement GetSameObject ()
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
234 {
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
235 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
236 req.AddUnitTypeRequirement(unitType1, 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
237 return req;
109
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
238 }
f5f66483032a Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 108
diff changeset
239
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
240 public override RequiresAtLeastNUnitsRequirement GetDifferentObject ()
124
14a007cf2446 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
241 {
14a007cf2446 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
242 RequiresAtLeastNUnitsRequirement req = new RequiresAtLeastNUnitsRequirement();
138
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
243 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
244 GameSystem gameSystem = new GameSystem("system", "system", factory);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
245 Race race = new Race("race", "race", gameSystem, factory);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
246 req.AddUnitTypeRequirement(new UnitType("id2", "Type 2", race), 2);
11faab6c712a Re #140: Add equality methods
IBBoard <dev@ibboard.co.uk>
parents: 130
diff changeset
247 return req;
102
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
248 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
249 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
250 }
a3bc8174299f Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
251