# HG changeset patch # User IBBoard # Date 1282400681 0 # Node ID 6ba8ac49a923a4e08407329ac90bff6b3c8cdd82 # Parent 38cd18f2fefa3c4a8c67b0259f62182b35fe0f74 Re #46: Add NUnit helper methods * First import of test project * Add tests for initial "Array contains" diff -r 38cd18f2fefa -r 6ba8ac49a923 AssemblyInfo.cs --- /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("")] + diff -r 38cd18f2fefa -r 6ba8ac49a923 Constraints/ArrayContainsConstraintTest.cs --- /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 constraint = new ArrayContainsConstraint(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 constraint = new ArrayContainsConstraint("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(); + Assert.That(constraint.Matches(new string[] { "something" }), Is.False); + Assert.That(constraint.Matches(new string[] { "" }), Is.False); + } + + [Test()] + public void TestArrayContainsReturnsTrueForSimpleMatch() + { + ArrayContainsConstraint constraint = new ArrayContainsConstraint("str"); + Assert.That(constraint.Matches(new string[] { "str" }), Is.True); + constraint = new ArrayContainsConstraint(""); + Assert.That(constraint.Matches(new string[] { "" }), Is.True); + + constraint = new ArrayContainsConstraint(); + Assert.That(constraint.Matches(new string[0]), Is.True); + } + + [Test()] + public void TestArrayContainsReturnsCorrectErrorForSimpleNonMatch() + { + ArrayContainsConstraint constraint = new ArrayContainsConstraint("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: \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(); + 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: \n")); + } + } +} + diff -r 38cd18f2fefa -r 6ba8ac49a923 DoesTest.cs --- /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() + { + } + } +} + diff -r 38cd18f2fefa -r 6ba8ac49a923 IBBoard.NUnit.Tests.csproj --- /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 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {2025A316-8377-4454-807C-3C4ED02DF4D5} + Library + IBBoard.NUnit.Tests + IBBoard.NUnit.Tests + + + true + full + false + bin\Debug + DEBUG + prompt + 4 + false + + + none + false + bin\Release + prompt + 4 + false + + + + + + + + + + + + + + + + + + + {C52AFD32-B869-4E14-AACE-2846AD2CC742} + IBBoard.NUnit + + + + + + \ No newline at end of file