134
|
1 // This file (ValidationTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
|
115
|
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;
|
134
|
5 using NUnit.Framework;
|
115
|
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()
|
134
|
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 }
|
115
|
22 }
|
134
|
23 }
|
|
24
|
|
25 [Test()]
|
|
26 public void TestPassAndNAAreTreatedAsPass()
|
|
27 {
|
|
28 Validation mask = Validation.Passed;
|
|
29 Assert.That(Validation.Passed & mask, Is.EqualTo(Validation.Passed));
|
|
30 Assert.That(Validation.NotApplicable & mask, Is.EqualTo(Validation.Passed));
|
|
31 }
|
|
32
|
|
33 [Test()]
|
|
34 public void TestFailedAndNAAreTreatedAsFailed()
|
|
35 {
|
|
36 Validation mask = Validation.Failed;
|
|
37 Assert.That(Validation.Failed & mask, Is.EqualTo(Validation.Failed));
|
|
38 Assert.That(Validation.NotApplicable & mask, Is.EqualTo(Validation.Failed));
|
|
39 }
|
|
40
|
|
41 [Test()]
|
|
42 public void TestValidatesAsOkaySuccedesForPassedAndNA()
|
|
43 {
|
|
44 Assert.That(Validates.AsOkay(Validation.Passed), Is.True);
|
|
45 Assert.That(Validates.AsOkay(Validation.NotApplicable), Is.True);
|
|
46 Assert.That(Validates.AsOkay(Validation.Failed), Is.False);
|
|
47 }
|
|
48
|
|
49 [Test()]
|
|
50 public void TestValidatesAsNotOkaySuccedesForFailedAndNA()
|
|
51 {
|
|
52 Assert.That(Validates.AsNotOkay(Validation.Failed), Is.True);
|
|
53 Assert.That(Validates.AsNotOkay(Validation.NotApplicable), Is.True);
|
|
54 Assert.That(Validates.AsNotOkay(Validation.Passed), Is.False);
|
115
|
55 }
|
|
56 }
|
|
57 }
|
|
58
|