changeset 1:6ba8ac49a923

Re #46: Add NUnit helper methods * First import of test project * Add tests for initial "Array contains"
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Aug 2010 14:24:41 +0000
parents 38cd18f2fefa
children 664e47280811
files AssemblyInfo.cs Constraints/ArrayContainsConstraintTest.cs DoesTest.cs IBBoard.NUnit.Tests.csproj
diffstat 4 files changed, 184 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AssemblyInfo.cs	Sat Aug 21 14:24:41 2010 +0000
@@ -0,0 +1,30 @@
+//  This file (AssemblyInfo.cs) is a part of the IBBoard.NUnit.Tests project and is copyright 2010 IBBoard
+// 
+// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, 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.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("IBBoard.NUnit.Tests")]
+[assembly: AssemblyDescription("Tests for the NUnit extension methods")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("2010 IBBoard")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("0.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Constraints/ArrayContainsConstraintTest.cs	Sat Aug 21 14:24:41 2010 +0000
@@ -0,0 +1,85 @@
+//  This file (ArrayContainsConstraintTest.cs) is a part of the IBBoard.NUnit.Tests project and is copyright 2010 IBBoard
+// 
+// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, 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 IBBoard.NUnit.Constraints;
+using NUnit.Framework.SyntaxHelpers;
+namespace IBBoard.NUnit.Tests
+{
+	[TestFixture()]
+	public class ArrayContainsConstraintTest
+	{
+		[Test()]
+		public void TestArrayContainsThrowsExceptionForNonArray()
+		{
+			ArrayContainsConstraint<string> constraint = new ArrayContainsConstraint<string>(new string[0]);
+			
+			try
+			{
+				constraint.Matches(new object());
+				Assert.Fail("Exception not thrown");
+			}
+			catch (ArgumentException ex)
+			{
+				Assert.That(ex.Message, Is.EqualTo("The actual value must be an array"));
+			}
+		}
+		
+		[Test()]
+		public void TestArrayContainsReturnsFalseForSimpleNonMatch()
+		{
+			ArrayContainsConstraint<string> constraint = new ArrayContainsConstraint<string>("str");
+			Assert.That(constraint.Matches(new string[] { "something" }), Is.False);
+			Assert.That(constraint.Matches(new string[] { "" }), Is.False);
+			Assert.That(constraint.Matches(new string[0]), Is.False);
+			
+			constraint = new ArrayContainsConstraint<string>();
+			Assert.That(constraint.Matches(new string[] { "something" }), Is.False);
+			Assert.That(constraint.Matches(new string[] { "" }), Is.False);
+		}
+		
+		[Test()]
+		public void TestArrayContainsReturnsTrueForSimpleMatch()
+		{
+			ArrayContainsConstraint<string> constraint = new ArrayContainsConstraint<string>("str");
+			Assert.That(constraint.Matches(new string[] { "str" }), Is.True);
+			constraint = new ArrayContainsConstraint<string>("");
+			Assert.That(constraint.Matches(new string[] { "" }), Is.True);
+			
+			constraint = new ArrayContainsConstraint<string>();
+			Assert.That(constraint.Matches(new string[0]), Is.True);
+		}
+		
+		[Test()]
+		public void TestArrayContainsReturnsCorrectErrorForSimpleNonMatch()
+		{
+			ArrayContainsConstraint<string> constraint = new ArrayContainsConstraint<string>("str");
+			Assert.That(constraint.Matches(new string[] { "something" }), Is.False);
+			MessageWriter mw = new TextMessageWriter();
+			constraint.WriteMessageTo(mw);
+			Console.WriteLine(mw.ToString());
+			Assert.That(mw.ToString(), Is.EqualTo("  Expected: \"str\"\n  But was:  \"something\"\n  Incorrect value at 0\n"));
+			
+			Assert.That(constraint.Matches(new string[] { "" }), Is.False);
+			mw = new TextMessageWriter();
+			constraint.WriteMessageTo(mw);
+			Console.WriteLine(mw.ToString());
+			Assert.That(mw.ToString(), Is.EqualTo("  Expected: \"str\"\n  But was:  <string.Empty>\n  Incorrect value at 0\n"));
+			
+			Assert.That(constraint.Matches(new string[0]), Is.False);
+			mw = new TextMessageWriter();
+			constraint.WriteMessageTo(mw);
+			Console.WriteLine(mw.ToString());
+			Assert.That(mw.ToString(), Is.EqualTo("  Expected: \"str\"\n  But was:  Empty array\n"));
+			
+			constraint = new ArrayContainsConstraint<string>();
+			Assert.That(constraint.Matches(new string[] { "" }), Is.False);
+			mw = new TextMessageWriter();
+			constraint.WriteMessageTo(mw);
+			Console.WriteLine(mw.ToString());
+			Assert.That(mw.ToString(), Is.EqualTo("  Expected: Empty array\n  But was:  <string.Empty>\n"));
+		}
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DoesTest.cs	Sat Aug 21 14:24:41 2010 +0000
@@ -0,0 +1,14 @@
+//  This file (MyClass.cs) is a part of the IBBoard.NUnit project and is copyright 2010 IBBoard
+// 
+// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, 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;
+namespace IBBoard.NUnit.Tests
+{
+	public class MyClass
+	{
+		public MyClass()
+		{
+		}
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IBBoard.NUnit.Tests.csproj	Sat Aug 21 14:24:41 2010 +0000
@@ -0,0 +1,55 @@
+<?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>
+    <ProductVersion>8.0.50727</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{2025A316-8377-4454-807C-3C4ED02DF4D5}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>IBBoard.NUnit.Tests</RootNamespace>
+    <AssemblyName>IBBoard.NUnit.Tests</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="DoesTest.cs" />
+    <Compile Include="Constraints\ArrayContainsConstraintTest.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <MonoDevelop>
+      <Properties InternalTargetFrameworkVersion="3.5" />
+    </MonoDevelop>
+  </ProjectExtensions>
+  <ItemGroup>
+    <ProjectReference Include="..\IBBoard.NUnit\IBBoard.NUnit.csproj">
+      <Project>{C52AFD32-B869-4E14-AACE-2846AD2CC742}</Project>
+      <Name>IBBoard.NUnit</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Constraints\" />
+  </ItemGroup>
+</Project>
\ No newline at end of file