BackgroundWorkerTest.cs 1.2 KB

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