← Back to team overview

nunit-core team mailing list archive

[Merge] lp:~cvetomir-todorov/nunitv2/bug524474 into lp:nunitv2

 

Cvetomir Todorov has proposed merging lp:~cvetomir-todorov/nunitv2/bug524474 into lp:nunitv2.

Requested reviews:
  NUnit Core Developers (nunit-core)
Related bugs:
  #524474 NUnit GUI issue: /exclude categories are saved each time
  https://bugs.launchpad.net/bugs/524474

-- 
https://code.launchpad.net/~cvetomir-todorov/nunitv2/bug524474/+merge/34638
Your team NUnit Core Developers is requested to review the proposed merge of lp:~cvetomir-todorov/nunitv2/bug524474 into lp:nunitv2.
=== modified file 'src/ConsoleRunner/tests/nunit-console.tests.build'
--- src/ConsoleRunner/tests/nunit-console.tests.build	2009-04-22 01:21:06 +0000
+++ src/ConsoleRunner/tests/nunit-console.tests.build	2010-09-05 16:15:54 +0000
@@ -24,6 +24,7 @@
         <include name="${current.test.dir}/nunit.framework.tests.dll"/>
         <include name="${current.test.dir}/test-assembly.dll"/>
         <include name="${current.test.dir}/mock-assembly.dll"/>
+		<include name="${current.test.dir}/nonamespace-assembly.dll"/>
       </references>
     </csc>
   </target>

=== modified file 'src/GuiComponents/UiKit/TestTree.cs'
--- src/GuiComponents/UiKit/TestTree.cs	2009-04-18 02:24:12 +0000
+++ src/GuiComponents/UiKit/TestTree.cs	2010-09-05 16:15:54 +0000
@@ -6,6 +6,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.ComponentModel;
 using System.Drawing;
 using System.Data;
@@ -26,7 +27,7 @@
 		// Contains all available categories, whether
 		// selected or not. Unselected members of this
 		// list are displayed in selectedList
-		private IList availableCategories;
+		private IList availableCategories = new List<string>();
 
 		// Our test loader
 		private TestLoader loader;
@@ -234,8 +235,11 @@
 			foreach( string category in categories )
 			{
 				if ( availableCategories.Contains( category ) )
-				{
-					selectedList.Items.Add( category );
+				{
+					if (!selectedList.Items.Contains(category))
+					{
+						selectedList.Items.Add(category);
+					}
 					availableList.Items.Remove( category );
 
 					this.excludeCheckbox.Checked = exclude;

=== added file 'src/GuiComponents/tests/TestTreeTests.cs'
--- src/GuiComponents/tests/TestTreeTests.cs	1970-01-01 00:00:00 +0000
+++ src/GuiComponents/tests/TestTreeTests.cs	2010-09-05 16:15:54 +0000
@@ -0,0 +1,47 @@
+// ****************************************************************
+// Copyright 2010, Charlie Poole
+// This is free software licensed under the NUnit license. You may
+// obtain a copy of the license at http://nunit.org
+// ****************************************************************
+
+using System;
+using System.Collections;
+using System.Reflection;
+using NUnit.Framework;
+
+namespace NUnit.UiKit.Tests
+{
+	[TestFixture]
+	public class TestTreeTests
+	{
+		[Test]
+		public void SameCategoryShouldNotBeSelectedMoreThanOnce()
+		{
+			// arrange
+			var target = new TestTree();
+
+			// we need to populate the available categories
+			// this can be done via TestLoader but this way the test is isolated
+			FieldInfo fieldInfo = typeof (TestTree).GetField("availableCategories", BindingFlags.NonPublic | BindingFlags.Instance);
+			Assert.IsNotNull(fieldInfo, "The field 'availableCategories' should be found.");
+			object fieldValue = fieldInfo.GetValue(target);
+			Assert.IsNotNull(fieldValue, "The value of 'availableCategories' should not be null.");
+			IList availableCategories = fieldValue as IList;
+			Assert.IsNotNull(availableCategories, "'availableCategories' field should be of type IList.");
+
+			string[] expectedSelectedCategories = new[] { "Foo", "MockCategory" };
+			foreach (string availableCategory in expectedSelectedCategories)
+			{
+				availableCategories.Add(availableCategory);
+			}
+
+			// act
+			target.SelectCategories(expectedSelectedCategories, true);
+			target.SelectCategories(expectedSelectedCategories, true);
+			string[] actualSelectedCategories = target.SelectedCategories;
+
+			// assert
+			CollectionAssert.AreEquivalent(expectedSelectedCategories, actualSelectedCategories);
+		}
+	}
+}

=== modified file 'src/GuiComponents/tests/nunit.uikit.tests.csproj'
--- src/GuiComponents/tests/nunit.uikit.tests.csproj	2010-08-06 18:37:35 +0000
+++ src/GuiComponents/tests/nunit.uikit.tests.csproj	2010-09-05 16:15:54 +0000
@@ -149,6 +149,7 @@
     <Compile Include="StatusBarTests.cs" />
     <Compile Include="TestSuiteTreeNodeTests.cs" />
     <Compile Include="TestSuiteTreeViewFixture.cs" />
+    <Compile Include="TestTreeTests.cs" />
     <Compile Include="VisualStateTests.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />