Mercurial > repos > IBBoard.WarFoundry.API.Tests
comparison 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 |
comparison
equal
deleted
inserted
replaced
114:4fcac7e162fe | 115:bcca07bee8ea |
---|---|
1 // This file (ValidationTests.cs) is a part of the IBBoard.WarFoundry.API.Tests 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 using NUnit.Framework; | |
6 using NUnit.Framework.SyntaxHelpers; | |
7 | |
8 namespace IBBoard.WarFoundry.API.Objects.Requirement | |
9 { | |
10 [TestFixture()] | |
11 public class ValidationTests | |
12 { | |
13 [Test()] | |
14 public void TestEnumValuesAreDifferent() | |
15 { | |
16 foreach(Validation val1 in Enum.GetValues(typeof(Validation))) | |
17 { | |
18 foreach(Validation val2 in Enum.GetValues(typeof(Validation))) | |
19 { | |
20 Assert.That(val1.Equals(val2) || ((int)val1) != ((int)val2)); | |
21 } | |
22 } | |
23 } | |
24 | |
25 public void TestPassAndNAAreTreatedAsPass() | |
26 { | |
27 Validation mask = Validation.Passed; | |
28 Assert.That(Validation.Passed | mask, Is.EqualTo(Validation.Passed)); | |
29 Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Passed)); | |
30 } | |
31 | |
32 public void TestFailedAndNAAreTreatedAsFailed() | |
33 { | |
34 Validation mask = Validation.Failed; | |
35 Assert.That(Validation.Failed | mask, Is.EqualTo(Validation.Failed)); | |
36 Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Failed)); | |
37 } | |
38 | |
39 public void TestValidatesAsOkaySuccedesForPassedAndNA() | |
40 { | |
41 Assert.That(Validates.AsOkay(Validation.Passed), Is.True); | |
42 Assert.That(Validates.AsOkay(Validation.NotApplicable), Is.True); | |
43 Assert.That(Validates.AsOkay(Validation.Failed), Is.False); | |
44 } | |
45 | |
46 public void TestValidatesAsNotOkaySuccedesForPassedAndNA() | |
47 { | |
48 Assert.That(Validates.AsNotOkay(Validation.Failed), Is.True); | |
49 Assert.That(Validates.AsNotOkay(Validation.NotApplicable), Is.True); | |
50 Assert.That(Validates.AsNotOkay(Validation.Passed), Is.False); | |
51 } | |
52 } | |
53 } | |
54 |