annotate API/Objects/Requirement/RequirementHandlerTests.cs @ 146:8c519a44e699

Re #345: Add failure message to requirements * Add testing of failure messages for "allows adding"
author IBBoard <dev@ibboard.co.uk>
date Sun, 01 May 2011 19:17:11 +0000
parents 0d40d80226b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
133
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (RequirementHandlerTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
f64742dde5f9 Re #27: 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.
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Objects;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using NUnit.Framework.SyntaxHelpers;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API.Objects.Requirement.Mock;
143
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
10 using System.Collections.Generic;
133
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 namespace IBBoard.WarFoundry.API.Objects.Requirement
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 [TestFixture()]
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 public class RequirementHandlerTests
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 [Test()]
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 public void TestArmyWithNoRequirementsValidates()
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 MockRace race = new MockRace();
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 Army army = new Army(race, "test", 1000);
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Passed));
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 [Test()]
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 public void TestArmyWithFailingRequirementFails()
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 MockRace race = new MockRace();
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 MockUnitType mockUnitType = new MockUnitType();
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 mockUnitType.AddRequirement(new FailingRequirement());
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 race.AddUnitType(mockUnitType);
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 Army army = new Army(race, "test", 1000);
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Failed));
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 [Test()]
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 public void TestArmyWithPassingRequirementPasses()
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 MockRace race = new MockRace();
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 MockUnitType mockUnitType = new MockUnitType();
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 mockUnitType.AddRequirement(new PassingRequirement());
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 race.AddUnitType(mockUnitType);
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 Army army = new Army(race, "test", 1000);
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Passed));
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 [Test()]
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 public void TestArmyWithNotApplicableRequirementPasses()
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 MockRace race = new MockRace();
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 MockUnitType mockUnitType = new MockUnitType();
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 mockUnitType.AddRequirement(new NotApplicableRequirement());
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 race.AddUnitType(mockUnitType);
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 Army army = new Army(race, "test", 1000);
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Passed));
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 }
135
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
57
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
58 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
59 public void TestArmyWithMixedRequirementsWithFailFails()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
60 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
61 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
62 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
63 mockUnitType.AddRequirement(new PassingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
64 mockUnitType.AddRequirement(new FailingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
65 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
66 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
67 Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Failed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
68 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
69
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
70 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
71 public void TestArmyWithMixedRequirementsWithFailInOtherOrderFails()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
72 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
73 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
74 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
75 mockUnitType.AddRequirement(new FailingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
76 mockUnitType.AddRequirement(new PassingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
77 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
78 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
79 Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Failed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
80 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
81
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
82 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
83 public void TestArmyWithMixedRequirementsWithNoFailsPasses()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
84 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
85 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
86 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
87 mockUnitType.AddRequirement(new PassingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
88 mockUnitType.AddRequirement(new NotApplicableRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
89 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
90 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
91 Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Passed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
92 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
93
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
94 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
95 public void TestCanAddToArmyWithNoRequirementsValidates()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
96 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
97 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
98 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
99 Assert.That(RequirementHandler.AllowsAdding(new MockUnitType(), army), Is.EqualTo(Validation.Passed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
100 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
101
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
102 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
103 public void TestCanAddToArmyWithFailingRequirementFails()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
104 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
105 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
106 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
107 mockUnitType.AddRequirement(new FailingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
108 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
109 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
110 Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Failed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
111 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
112
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
113 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
114 public void TestCanAddToArmyWithPassingRequirementPasses()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
115 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
116 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
117 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
118 mockUnitType.AddRequirement(new PassingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
119 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
120 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
121 Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Passed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
122 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
123
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
124 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
125 public void TestCanAddToArmyWithNotApplicableRequirementPasses()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
126 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
127 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
128 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
129 mockUnitType.AddRequirement(new NotApplicableRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
130 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
131 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
132 Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Passed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
133 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
134
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
135 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
136 public void TestCanAddToArmyWithMixedRequirementsWithFailFails()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
137 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
138 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
139 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
140 mockUnitType.AddRequirement(new PassingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
141 mockUnitType.AddRequirement(new FailingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
142 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
143 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
144 Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Failed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
145 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
146
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
147 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
148 public void TestCanAddToArmyWithMixedRequirementsWithFailInOtherOrderFails()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
149 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
150 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
151 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
152 mockUnitType.AddRequirement(new FailingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
153 mockUnitType.AddRequirement(new PassingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
154 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
155 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
156 Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Failed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
157 }
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
158
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
159 [Test()]
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
160 public void TestCanAddToArmyWithMixedRequirementsWithNoFailsPasses()
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
161 {
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
162 MockRace race = new MockRace();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
163 MockUnitType mockUnitType = new MockUnitType();
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
164 mockUnitType.AddRequirement(new PassingRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
165 mockUnitType.AddRequirement(new NotApplicableRequirement());
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
166 race.AddUnitType(mockUnitType);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
167 Army army = new Army(race, "test", 1000);
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
168 Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Passed));
8c3bba80a25e Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
169 }
143
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
170
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
171 [Test()]
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
172 public void TestArmyWithMixedRequirementsGetsExpectedFailureMessageCount()
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
173 {
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
174 MockRace race = new MockRace();
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
175 MockUnitType mockUnitType = new MockUnitType();
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
176 mockUnitType.AddRequirement(new PassingRequirement());
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
177 mockUnitType.AddRequirement(new NotApplicableRequirement());
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
178 mockUnitType.AddRequirement(new FailingRequirement());
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
179 mockUnitType.AddRequirement(new FailingRequirement());
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
180 race.AddUnitType(mockUnitType);
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
181 Army army = new Army(race, "test", 1000);
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
182 ICollection<string> failureMessages;
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
183 RequirementHandler.ValidateArmy(army, out failureMessages);
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
184 Assert.That(failureMessages, Has.Count(2));
6fdb76d48e04 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 135
diff changeset
185 }
145
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
186
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
187 [Test()]
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
188 public void TestAddingToArmyWithMixedRequirementsGetsExpectedFailureMessageCount()
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
189 {
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
190 MockRace race = new MockRace();
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
191 MockUnitType mockUnitType = new MockUnitType();
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
192 mockUnitType.AddRequirement(new PassingRequirement());
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
193 mockUnitType.AddRequirement(new NotApplicableRequirement());
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
194 mockUnitType.AddRequirement(new FailingRequirement());
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
195 mockUnitType.AddRequirement(new FailingRequirement());
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
196 race.AddUnitType(mockUnitType);
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
197 Army army = new Army(race, "test", 1000);
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
198 ICollection<string> failureMessages;
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
199 RequirementHandler.AllowsAdding(mockUnitType, army, out failureMessages);
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
200 Assert.That(failureMessages, Has.Count(2));
0d40d80226b8 Re #33: Add centralised requirement checker
IBBoard <dev@ibboard.co.uk>
parents: 143
diff changeset
201 }
133
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204