annotate API/Objects/Requirement/Mock/AbstractFixedRequirement.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 cd95fc6400b2
children 32b3e41bc8f0
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 (AbstractFixedRequirement.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
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 namespace IBBoard.WarFoundry.API.Objects.Requirement.Mock
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 public class AbstractFixedRequirement : IRequirement
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 private Validation result;
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 public AbstractFixedRequirement(Validation fixedResult)
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 result = fixedResult;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 }
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 public Validation AllowsAdding (WarFoundryObject wfObject, Army toArmy)
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 return result;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 public Validation ValidatesArmy (Army army)
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 return result;
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 }
141
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
26
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
27 public string GetValidationMessage (Army army)
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
28 {
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
29 return (result.Equals(Validation.Failed)) ? "Validation failed" : "";
cd95fc6400b2 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
30 }
146
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
31
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
32 public string GetAllowsAddingMessage (UnitType toAdd, Army toArmy)
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
33 {
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
34 return (result.Equals(Validation.Failed)) ? "Validation failed" : "";
8c519a44e699 Re #345: Add failure message to requirements
IBBoard <dev@ibboard.co.uk>
parents: 141
diff changeset
35 }
133
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }
f64742dde5f9 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38