Prechádzať zdrojové kódy

2007-08-01 Atsushi Enomoto <[email protected]>

	* BackgroundWorker.cs : remove extra MonoTODOs.

	* BackgroundWorkerTest.cs : new test to clear some doubts on impl.

	* System_test.dll.sources : added BackgroundWorkerTest.cs.


svn path=/trunk/mcs/; revision=83156
Atsushi Eno 18 rokov pred
rodič
commit
044c5019fa

+ 4 - 0
mcs/class/System/ChangeLog

@@ -1,3 +1,7 @@
+2007-08-01  Atsushi Enomoto  <[email protected]>
+
+	* System_test.dll.sources : added BackgroundWorkerTest.cs.
+
 2007-07-20  Jb Evain  <[email protected]>
 
 	* Makefile: no need for the deps for installing in 2.1.

+ 0 - 3
mcs/class/System/System.ComponentModel/BackgroundWorker.cs

@@ -72,13 +72,11 @@ namespace System.ComponentModel
 			set { support_cancel = value; }
 		}
 
-		//[MonoTODO ("What should happen when IsBusy != true?")]
 		public void CancelAsync ()
 		{
 			if (!support_cancel)
 				throw new InvalidOperationException ("This background worker does not support cancellation.");
 
-			// FIXME: verify the expected behavior
 			if (!IsBusy)
 				return;
 
@@ -99,7 +97,6 @@ namespace System.ComponentModel
 			ReportProgress (percentProgress, null);
 		}
 
-		[MonoTODO ("What should happen when IsBusy != true?")]
 		public void ReportProgress (int percentProgress, object userState)
 		{
 			if (!WorkerReportsProgress)

+ 4 - 0
mcs/class/System/System.ComponentModel/ChangeLog

@@ -1,3 +1,7 @@
+2007-08-01  Atsushi Enomoto  <[email protected]>
+
+	* BackgroundWorker.cs : remove extra MonoTODOs.
+
 2007-07-21  Gert Driesen  <[email protected]>
 
 	* DisplayNameAttribute.cs: To match MS, do not change null DisplayName

+ 1 - 0
mcs/class/System/System_test.dll.sources

@@ -108,6 +108,7 @@ System.Collections.Specialized/StringCollectionTest.cs
 System.Collections.Specialized/StringDictionaryTest.cs
 System.ComponentModel/ArrayConverterTests.cs
 System.ComponentModel/AttributeProviderAttributeTest.cs
+System.ComponentModel/BackgroundWorkerTest.cs
 System.ComponentModel/BindingListTest.cs
 System.ComponentModel/ByteConverterTests.cs
 System.ComponentModel/CollectionConverterTest.cs

+ 61 - 0
mcs/class/System/Test/System.ComponentModel/BackgroundWorkerTest.cs

@@ -0,0 +1,61 @@
+//
+// BackgroundWorkerTest.cs
+//
+// Author:
+// 	Atsushi Enomoto  <[email protected]>
+//
+// Copyright (C) 2007 Novell, Inc.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ComponentModel
+{
+	[TestFixture]
+	public class BackgroundWorkerTest
+	{
+		[Test]
+		[ExpectedException (typeof (InvalidOperationException))]
+		public void ReportProgressNoReportingSupported ()
+		{
+			BackgroundWorker b = new BackgroundWorker ();
+			Assert.IsFalse (b.IsBusy, "#1");
+			b.ReportProgress (0);
+		}
+
+		[Test]
+		public void ReportProgressNonBusy ()
+		{
+			BackgroundWorker b = new BackgroundWorker ();
+			b.WorkerReportsProgress = true;
+			Assert.IsFalse (b.IsBusy, "#1");
+			b.ReportProgress (0);
+		}
+
+		[Test]
+		[ExpectedException (typeof (InvalidOperationException))]
+		public void CancelAsyncNoCancellationSupported ()
+		{
+			BackgroundWorker b = new BackgroundWorker ();
+			Assert.IsFalse (b.IsBusy, "#1");
+			b.CancelAsync ();
+		}
+
+		[Test]
+		public void CancelAsyncNonBusy ()
+		{
+			BackgroundWorker b = new BackgroundWorker ();
+			b.WorkerSupportsCancellation = true;
+			Assert.IsFalse (b.IsBusy, "#1");
+			b.CancelAsync ();
+		}
+	}
+}
+
+#endif

+ 4 - 0
mcs/class/System/Test/System.ComponentModel/ChangeLog

@@ -1,3 +1,7 @@
+2007-08-01  Atsushi Enomoto  <[email protected]>
+
+	* BackgroundWorkerTest.cs : new test to clear some doubts on impl.
+
 2007-07-21  Gert Driesen  <[email protected]>
 
 	* DisplayNameAttribute.cs: Added ctor tests. Fixed tests to pass on