annotate API/Objects/Requirement/ValidationTests.cs @ 134:4e1a477c38d8

Re #27: Unit requirements * Tidy up line endings * Fix unit tests to mask (logical AND) instead of ORing
author IBBoard <dev@ibboard.co.uk>
date Fri, 22 Apr 2011 10:30:26 +0000
parents 49fb69ea13f2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
134
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
1 // This file (ValidationTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
115
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;
134
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
5 using NUnit.Framework;
115
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()
134
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
15 {
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
16 foreach(Validation val1 in Enum.GetValues(typeof(Validation)))
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
17 {
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
18 foreach(Validation val2 in Enum.GetValues(typeof(Validation)))
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
19 {
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
20 Assert.That(val1.Equals(val2) || ((int)val1) != ((int)val2));
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
21 }
115
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 }
134
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
23 }
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
24
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
25 [Test()]
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
26 public void TestPassAndNAAreTreatedAsPass()
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
27 {
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
28 Validation mask = Validation.Passed;
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
29 Assert.That(Validation.Passed & mask, Is.EqualTo(Validation.Passed));
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
30 Assert.That(Validation.NotApplicable & mask, Is.EqualTo(Validation.Passed));
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
31 }
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
32
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
33 [Test()]
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
34 public void TestFailedAndNAAreTreatedAsFailed()
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
35 {
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
36 Validation mask = Validation.Failed;
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
37 Assert.That(Validation.Failed & mask, Is.EqualTo(Validation.Failed));
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
38 Assert.That(Validation.NotApplicable & mask, Is.EqualTo(Validation.Failed));
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
39 }
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
40
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
41 [Test()]
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
42 public void TestValidatesAsOkaySuccedesForPassedAndNA()
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
43 {
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
44 Assert.That(Validates.AsOkay(Validation.Passed), Is.True);
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
45 Assert.That(Validates.AsOkay(Validation.NotApplicable), Is.True);
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
46 Assert.That(Validates.AsOkay(Validation.Failed), Is.False);
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
47 }
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
48
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
49 [Test()]
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
50 public void TestValidatesAsNotOkaySuccedesForFailedAndNA()
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
51 {
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
52 Assert.That(Validates.AsNotOkay(Validation.Failed), Is.True);
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
53 Assert.That(Validates.AsNotOkay(Validation.NotApplicable), Is.True);
4e1a477c38d8 Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents: 116
diff changeset
54 Assert.That(Validates.AsNotOkay(Validation.Passed), Is.False);
115
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 }
bcca07bee8ea Re #27: Unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58