# HG changeset patch # User IBBoard # Date 1303827331 0 # Node ID 8b7aa46c4513f31600c687844d3e32e4e069756a # Parent e2d5fb7306b31a8124b0b0077d86cd99e745b666 Re #48: Collection equality * Add initial tests for list equality diff -r e2d5fb7306b3 -r 8b7aa46c4513 Collections/CollectionsTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Collections/CollectionsTest.cs Tue Apr 26 14:15:31 2011 +0000 @@ -0,0 +1,78 @@ +// This file (CollectionsTest.cs) is a part of the IBBoard.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 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 System.Collections.Generic; +using NUnit.Framework.SyntaxHelpers; + +namespace IBBoard.Collections +{ + [TestFixture()] + public class CollectionsTest + { + [Test] + public void TestSelfEquality() + { + IList list1 = new List(); + Assert.That(Collections.AreEqual(list1, list1), Is.True); + } + + [Test()] + public void TestEmptyListEquality() + { + IList list1 = new List(); + IList list2 = new List(); + Assert.That(Collections.AreEqual(list1, list2), Is.True); + Assert.That(Collections.AreEqual(list2, list1), Is.True); + } + + [Test()] + public void TestEmptyAndNonEmptyListForInequality() + { + IList list1 = new List(); + IList list2 = new List(); + list1.Add(1); + Assert.That(Collections.AreEqual(list1, list2), Is.False); + Assert.That(Collections.AreEqual(list2, list1), Is.False); + } + + [Test] + public void TestDifferentNonEmptyListsForInequality() + { + IList list1 = new List(); + list1.Add(1); + IList list2 = new List(); + list2.Add(2); + Assert.That(Collections.AreEqual(list1, list2), Is.False); + Assert.That(Collections.AreEqual(list2, list1), Is.False); + } + + [Test] + public void TestMatchingNonEmptyListsForEquality() + { + IList list1 = new List(); + list1.Add(1); + IList list2 = new List(); + list2.Add(1); + Assert.That(Collections.AreEqual(list1, list2), Is.True); + Assert.That(Collections.AreEqual(list2, list1), Is.True); + } + + [Test] + public void TestDifferentOrderedListsForInequality() + { + IList list1 = new List(); + list1.Add(1); + list1.Add(2); + list1.Add(3); + IList list2 = new List(); + list2.Add(3); + list2.Add(2); + list2.Add(1); + Assert.That(Collections.AreEqual(list1, list2), Is.False); + Assert.That(Collections.AreEqual(list2, list1), Is.False); + } + } +} + diff -r e2d5fb7306b3 -r 8b7aa46c4513 IBBoard.Tests.csproj --- a/IBBoard.Tests.csproj Mon Apr 25 10:48:09 2011 +0000 +++ b/IBBoard.Tests.csproj Tue Apr 26 14:15:31 2011 +0000 @@ -1,4 +1,4 @@ - + Debug @@ -73,6 +73,7 @@ + @@ -160,4 +161,7 @@ PreserveNewest + + + \ No newline at end of file