Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/Requirement/Validation.cs @ 339:50cd43bf51b3
Re #27: Unit requirements
* Add tri-state enum (passed, failed, not applicable) and helper class
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 03 Apr 2011 19:40:42 +0000 |
parents | |
children | 47acc63cf529 |
comparison
equal
deleted
inserted
replaced
338:4497ebce9a57 | 339:50cd43bf51b3 |
---|---|
1 // This file (Validation.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2011 IBBoard | |
2 // | |
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. | |
4 using System; | |
5 | |
6 namespace IBBoard.WarFoundry.API.Objects.Requirement | |
7 { | |
8 /// <summary> | |
9 /// A custom enum for validation to distinguish between "validation wasn't necessary" and "validation passed". | |
10 /// This should allow for easier handling of failed requirements later being satisfied. | |
11 /// </summary> | |
12 public enum Validation | |
13 { | |
14 Passed = 1, | |
15 Failed = 2, | |
16 NotApplicable = 3 | |
17 } | |
18 | |
19 /// <summary> | |
20 /// A helper class to handle the enums and treat them as booleans where a pass/fail is all that is necessary. | |
21 /// </summary> | |
22 public class Validates | |
23 { | |
24 /// <summary> | |
25 /// Checks if the validation was okay (pass or not applicable) | |
26 /// </summary> | |
27 /// <returns> | |
28 /// <code>true</code> if the validation passed or was not applicable, else <code>false</code> | |
29 /// </returns> | |
30 /// <param name='passed'> | |
31 /// The Validation enum value to check | |
32 /// </param> | |
33 public static bool AsOkay(Validation result) | |
34 { | |
35 return (result | Validation.Passed) == Validation.Passed; | |
36 } | |
37 | |
38 /// <summary> | |
39 /// Checks if the validation result was not okay (failed or not applicable). Note that this is different | |
40 /// to <code>!Validates.AsOkay(result)</code> because this method treats not applicable as not being okay. | |
41 /// </summary> | |
42 /// <returns> | |
43 /// <code>true</code> if the validation failed or was not applicable, else <code>false</code> | |
44 /// </returns> | |
45 /// <param name='result'> | |
46 /// The Validation enum value to check | |
47 /// </param> | |
48 public static bool AsNotOkay (Validation result) | |
49 { | |
50 return (result | Validation.Failed) == Validation.Failed; | |
51 } | |
52 } | |
53 } | |
54 |