changeset 39:8b7aa46c4513

Re #48: Collection equality * Add initial tests for list equality
author IBBoard <dev@ibboard.co.uk>
date Tue, 26 Apr 2011 14:15:31 +0000
parents e2d5fb7306b3
children 8e8d0dc4ba20
files Collections/CollectionsTest.cs IBBoard.Tests.csproj
diffstat 2 files changed, 83 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /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<int> list1 = new List<int>();
+			Assert.That(Collections.AreEqual(list1, list1), Is.True);
+		}
+
+		[Test()]
+		public void TestEmptyListEquality()
+		{
+			IList<int> list1 = new List<int>();
+			IList<int> list2 = new List<int>();
+			Assert.That(Collections.AreEqual(list1, list2), Is.True);
+			Assert.That(Collections.AreEqual(list2, list1), Is.True);
+		}
+
+		[Test()]
+		public void TestEmptyAndNonEmptyListForInequality()
+		{
+			IList<int> list1 = new List<int>();
+			IList<int> list2 = new List<int>();
+			list1.Add(1);
+			Assert.That(Collections.AreEqual(list1, list2), Is.False);
+			Assert.That(Collections.AreEqual(list2, list1), Is.False);
+		}
+
+		[Test]
+		public void TestDifferentNonEmptyListsForInequality()
+		{
+			IList<int> list1 = new List<int>();
+			list1.Add(1);
+			IList<int> list2 = new List<int>();
+			list2.Add(2);
+			Assert.That(Collections.AreEqual(list1, list2), Is.False);
+			Assert.That(Collections.AreEqual(list2, list1), Is.False);
+		}
+
+		[Test]
+		public void TestMatchingNonEmptyListsForEquality()
+		{
+			IList<int> list1 = new List<int>();
+			list1.Add(1);
+			IList<int> list2 = new List<int>();
+			list2.Add(1);
+			Assert.That(Collections.AreEqual(list1, list2), Is.True);
+			Assert.That(Collections.AreEqual(list2, list1), Is.True);
+		}
+
+		[Test]
+		public void TestDifferentOrderedListsForInequality()
+		{
+			IList<int> list1 = new List<int>();
+			list1.Add(1);
+			list1.Add(2);
+			list1.Add(3);
+			IList<int> list2 = new List<int>();
+			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);
+		}
+	}
+}
+
--- 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 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -73,6 +73,7 @@
     <Compile Include="ArraysTests.cs" />
     <Compile Include="EqualityCheckerTests.cs" />
     <Compile Include="IO\StreamUtilTests.cs" />
+    <Compile Include="Collections\CollectionsTest.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
@@ -160,4 +161,7 @@
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Collections\" />
+  </ItemGroup>
 </Project>
\ No newline at end of file