changeset 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 4fcac7e162fe
children 49fb69ea13f2
files API/Objects/Requirement/ValidationTests.cs IBBoard.WarFoundry.API.Tests.csproj
diffstat 2 files changed, 57 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/API/Objects/Requirement/ValidationTests.cs	Sun Apr 03 19:40:06 2011 +0000
@@ -0,0 +1,54 @@
+// This file (ValidationTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
+// 
+// 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.
+using System;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace IBBoard.WarFoundry.API.Objects.Requirement
+{
+	[TestFixture()]
+	public class ValidationTests
+	{
+		[Test()]
+		public void TestEnumValuesAreDifferent()
+		{
+			foreach(Validation val1 in Enum.GetValues(typeof(Validation)))
+			{
+				foreach(Validation val2 in Enum.GetValues(typeof(Validation)))
+				{
+					Assert.That(val1.Equals(val2) || ((int)val1) != ((int)val2));
+				}
+			}
+		}
+
+		public void TestPassAndNAAreTreatedAsPass()
+		{
+			Validation mask = Validation.Passed;
+			Assert.That(Validation.Passed | mask, Is.EqualTo(Validation.Passed));
+			Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Passed));
+		}
+
+		public void TestFailedAndNAAreTreatedAsFailed()
+		{
+			Validation mask = Validation.Failed;
+			Assert.That(Validation.Failed | mask, Is.EqualTo(Validation.Failed));
+			Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Failed));
+		}
+
+		public void TestValidatesAsOkaySuccedesForPassedAndNA()
+		{
+			Assert.That(Validates.AsOkay(Validation.Passed), Is.True);
+			Assert.That(Validates.AsOkay(Validation.NotApplicable), Is.True);
+			Assert.That(Validates.AsOkay(Validation.Failed), Is.False);
+		}
+
+		public void TestValidatesAsNotOkaySuccedesForPassedAndNA()
+		{
+			Assert.That(Validates.AsNotOkay(Validation.Failed), Is.True);
+			Assert.That(Validates.AsNotOkay(Validation.NotApplicable), Is.True);
+			Assert.That(Validates.AsNotOkay(Validation.Passed), Is.False);
+		}
+	}
+}
+
--- a/IBBoard.WarFoundry.API.Tests.csproj	Sun Apr 03 19:03:13 2011 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Apr 03 19:40:06 2011 +0000
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -94,6 +94,7 @@
     <Compile Include="API\Objects\Requirement\RequiresAtLeastNUnitsRequirementTest.cs" />
     <Compile Include="API\Objects\Requirement\RequiresNoMoreThanNOfUnitTypeRequirementTest.cs" />
     <Compile Include="API\Objects\Requirement\UnitRequiresAtLeastNUnitsRequirementTest.cs" />
+    <Compile Include="API\Objects\Requirement\ValidationTests.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />