# HG changeset patch # User IBBoard # Date 1303743000 0 # Node ID 1ed310d10fc934e3ac744393f1e8e3db6a97fedb # Parent 2f2d6a6d9ffa0c5712a0b2098cfa5f2992194988 * Add abstract equality test class (contains basics) no-open-ticket diff -r 2f2d6a6d9ffa -r 1ed310d10fc9 AbstractEqualityTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AbstractEqualityTest.cs Mon Apr 25 14:50:00 2011 +0000 @@ -0,0 +1,61 @@ +// This file (AbstractEqualityTest.cs) is a part of the IBBoard.NUnit 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; +using NUnit.Framework; +using System.Reflection; + +namespace IBBoard.NUnit +{ + public abstract class AbstractEqualityTest + { + [Test] + public void TestEquality() + { + Assert.AreEqual(GetObject(), GetSameObject()); + Assert.AreEqual(GetSameObject(), GetObject()); + } + + [Test] + public void TestInequality() + { + Assert.AreNotEqual(GetObject(), GetDifferentObject()); + Assert.AreNotEqual(GetSameObject(), GetDifferentObject()); + Assert.AreNotEqual(GetDifferentObject(), GetObject()); + Assert.AreNotEqual(GetDifferentObject(), GetSameObject()); + } + + [Test] + public void TestReflexiveEquality() + { + Assert.AreEqual(GetObject(), GetObject()); + Assert.AreEqual(GetSameObject(), GetSameObject()); + Assert.AreEqual(GetDifferentObject(), GetDifferentObject()); + } + + [Test] + public void TestOtherInequality() + { + MethodInfo[] methodInfo = GetType().GetMethods(); + TEST_CLASS obj = GetObject(); + + foreach (MethodInfo method in methodInfo) + { + if (method.Name.StartsWith("GetOtherDifferent")) + { + TEST_CLASS otherObj = (TEST_CLASS)method.Invoke(this, new object[0]); + Assert.AreNotEqual(obj, otherObj, "Objects equal for "+method.Name); + Assert.AreNotEqual(otherObj, obj, "Objects equal for "+method.Name); + } + } + } + + public abstract TEST_CLASS GetObject(); + + public abstract TEST_CLASS GetSameObject(); + + public abstract TEST_CLASS GetDifferentObject(); + } +} + diff -r 2f2d6a6d9ffa -r 1ed310d10fc9 IBBoard.NUnit.csproj --- a/IBBoard.NUnit.csproj Sun Apr 03 13:30:30 2011 +0000 +++ b/IBBoard.NUnit.csproj Mon Apr 25 14:50:00 2011 +0000 @@ -1,4 +1,4 @@ - + Debug @@ -61,6 +61,7 @@ +