annotate API/Objects/Requirement/ValidationTests.cs @ 115:bcca07bee8ea

Re #27: Unit requirements * Add tri-state enum (passed, failed, not applicable)
author IBBoard <dev@ibboard.co.uk>
date Sun, 03 Apr 2011 19:40:06 +0000
parents
children 49fb69ea13f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
115
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (ValidationTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
bcca07bee8ea 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.
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using NUnit.Framework.SyntaxHelpers;
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 namespace IBBoard.WarFoundry.API.Objects.Requirement
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 [TestFixture()]
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public class ValidationTests
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 [Test()]
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public void TestEnumValuesAreDifferent()
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 foreach(Validation val1 in Enum.GetValues(typeof(Validation)))
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 foreach(Validation val2 in Enum.GetValues(typeof(Validation)))
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 Assert.That(val1.Equals(val2) || ((int)val1) != ((int)val2));
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 public void TestPassAndNAAreTreatedAsPass()
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 Validation mask = Validation.Passed;
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 Assert.That(Validation.Passed | mask, Is.EqualTo(Validation.Passed));
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Passed));
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 public void TestFailedAndNAAreTreatedAsFailed()
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 Validation mask = Validation.Failed;
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 Assert.That(Validation.Failed | mask, Is.EqualTo(Validation.Failed));
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Failed));
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 public void TestValidatesAsOkaySuccedesForPassedAndNA()
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 Assert.That(Validates.AsOkay(Validation.Passed), Is.True);
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 Assert.That(Validates.AsOkay(Validation.NotApplicable), Is.True);
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 Assert.That(Validates.AsOkay(Validation.Failed), Is.False);
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 public void TestValidatesAsNotOkaySuccedesForPassedAndNA()
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 {
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 Assert.That(Validates.AsNotOkay(Validation.Failed), Is.True);
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 Assert.That(Validates.AsNotOkay(Validation.NotApplicable), Is.True);
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 Assert.That(Validates.AsNotOkay(Validation.Passed), Is.False);
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54