2008-04-16 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System / Test / System.ComponentModel / BackgroundWorkerTest.cs
1 //
2 // BackgroundWorkerTest.cs
3 //
4 // Author:
5 //      Atsushi Enomoto  <atsushi@ximian.com>
6 //
7 // Copyright (C) 2007 Novell, Inc.
8 //
9
10 #if NET_2_0
11
12 using System;
13 using System.ComponentModel;
14 using System.Globalization;
15
16 using NUnit.Framework;
17
18 namespace MonoTests.System.ComponentModel
19 {
20         [TestFixture]
21         public class BackgroundWorkerTest
22         {
23                 [Test]
24                 [ExpectedException (typeof (InvalidOperationException))]
25                 public void ReportProgressNoReportingSupported ()
26                 {
27                         BackgroundWorker b = new BackgroundWorker ();
28                         Assert.IsFalse (b.IsBusy, "#1");
29                         b.ReportProgress (0);
30                 }
31
32                 [Test]
33                 public void ReportProgressNonBusy ()
34                 {
35                         BackgroundWorker b = new BackgroundWorker ();
36                         b.WorkerReportsProgress = true;
37                         Assert.IsFalse (b.IsBusy, "#1");
38                         b.ReportProgress (0);
39                 }
40
41                 [Test]
42                 [ExpectedException (typeof (InvalidOperationException))]
43                 public void CancelAsyncNoCancellationSupported ()
44                 {
45                         BackgroundWorker b = new BackgroundWorker ();
46                         Assert.IsFalse (b.IsBusy, "#1");
47                         b.CancelAsync ();
48                 }
49
50                 [Test]
51                 public void CancelAsyncNonBusy ()
52                 {
53                         BackgroundWorker b = new BackgroundWorker ();
54                         b.WorkerSupportsCancellation = true;
55                         Assert.IsFalse (b.IsBusy, "#1");
56                         b.CancelAsync ();
57                 }
58         }
59 }
60
61 #endif