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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/API/Objects/Requirement/ValidationTests.cs	Sun Apr 03 19:40:06 2011 +0000
     1.3 @@ -0,0 +1,54 @@
     1.4 +// This file (ValidationTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
     1.5 +// 
     1.6 +// 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.
     1.7 +using System;
     1.8 +using NUnit.Framework;
     1.9 +using NUnit.Framework.SyntaxHelpers;
    1.10 +
    1.11 +namespace IBBoard.WarFoundry.API.Objects.Requirement
    1.12 +{
    1.13 +	[TestFixture()]
    1.14 +	public class ValidationTests
    1.15 +	{
    1.16 +		[Test()]
    1.17 +		public void TestEnumValuesAreDifferent()
    1.18 +		{
    1.19 +			foreach(Validation val1 in Enum.GetValues(typeof(Validation)))
    1.20 +			{
    1.21 +				foreach(Validation val2 in Enum.GetValues(typeof(Validation)))
    1.22 +				{
    1.23 +					Assert.That(val1.Equals(val2) || ((int)val1) != ((int)val2));
    1.24 +				}
    1.25 +			}
    1.26 +		}
    1.27 +
    1.28 +		public void TestPassAndNAAreTreatedAsPass()
    1.29 +		{
    1.30 +			Validation mask = Validation.Passed;
    1.31 +			Assert.That(Validation.Passed | mask, Is.EqualTo(Validation.Passed));
    1.32 +			Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Passed));
    1.33 +		}
    1.34 +
    1.35 +		public void TestFailedAndNAAreTreatedAsFailed()
    1.36 +		{
    1.37 +			Validation mask = Validation.Failed;
    1.38 +			Assert.That(Validation.Failed | mask, Is.EqualTo(Validation.Failed));
    1.39 +			Assert.That(Validation.NotApplicable | mask, Is.EqualTo(Validation.Failed));
    1.40 +		}
    1.41 +
    1.42 +		public void TestValidatesAsOkaySuccedesForPassedAndNA()
    1.43 +		{
    1.44 +			Assert.That(Validates.AsOkay(Validation.Passed), Is.True);
    1.45 +			Assert.That(Validates.AsOkay(Validation.NotApplicable), Is.True);
    1.46 +			Assert.That(Validates.AsOkay(Validation.Failed), Is.False);
    1.47 +		}
    1.48 +
    1.49 +		public void TestValidatesAsNotOkaySuccedesForPassedAndNA()
    1.50 +		{
    1.51 +			Assert.That(Validates.AsNotOkay(Validation.Failed), Is.True);
    1.52 +			Assert.That(Validates.AsNotOkay(Validation.NotApplicable), Is.True);
    1.53 +			Assert.That(Validates.AsNotOkay(Validation.Passed), Is.False);
    1.54 +		}
    1.55 +	}
    1.56 +}
    1.57 +
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sun Apr 03 19:03:13 2011 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sun Apr 03 19:40:06 2011 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4 -<?xml version="1.0" encoding="utf-8"?>
     2.5 -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
     2.6 +<?xml version="1.0" encoding="utf-8"?>
     2.7 +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     2.8    <PropertyGroup>
     2.9      <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    2.10      <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    2.11 @@ -94,6 +94,7 @@
    2.12      <Compile Include="API\Objects\Requirement\RequiresAtLeastNUnitsRequirementTest.cs" />
    2.13      <Compile Include="API\Objects\Requirement\RequiresNoMoreThanNOfUnitTypeRequirementTest.cs" />
    2.14      <Compile Include="API\Objects\Requirement\UnitRequiresAtLeastNUnitsRequirementTest.cs" />
    2.15 +    <Compile Include="API\Objects\Requirement\ValidationTests.cs" />
    2.16    </ItemGroup>
    2.17    <ItemGroup>
    2.18      <None Include="app.config" />