Source/Csla.test/Threading/BackgroundWorkerTests.cs
/// <summary>
///A test for BackgroundWorker when reporting progress
///</summary>
A test for BackgroundWorker when reporting progress
A test for BackgroundWorker when reporting progress
[TestMethod]
    [ExpectedException(typeof(System.InvalidOperationException))]
    public void BackgroundWorker_CancelAsync_ThrowsInvalidOperationExceptionWhenWorkerSupportsCancellationIsFalse()
    {
      using (UnitTestContext context = GetContext())
      {
        BackgroundWorker target = new BackgroundWorker();
        target.DoWork += (o, e) =>
        {
          for (int i = 1; i < 11; i++)
          {
            Thread.Sleep(10);
          }
        };
        target.WorkerSupportsCancellation = false;
        target.RunWorkerAsync(null);
        try
        {
          target.CancelAsync();   
        }
        catch (InvalidOperationException ex)
        {
          context.Assert.Fail(ex);
        }
        context.Complete();
      }
    }
[ TestMethod ] [ ExpectedException ( typeof ( System . InvalidOperationException ) ) ] public void BackgroundWorker_CancelAsync_ThrowsInvalidOperationExceptionWhenWorkerSupportsCancellationIsFalse ( ) { using ( UnitTestContext context = GetContext ( ) ) { BackgroundWorker target = new BackgroundWorker ( ) ; target . DoWork += ( o , e ) => { for ( int i = 1 ; i < 11 ; i ++ ) { Thread . Sleep ( 10 ) ; } } ; target . WorkerSupportsCancellation = false ; target . RunWorkerAsync ( null ) ; try { target . CancelAsync ( ) ; } catch ( InvalidOperationException ex ) { context . Assert . Fail ( ex ) ; } context . Complete ( ) ; } }
A test for BackgroundWorker when reporting progress
A test for BackgroundWorker when reporting progress
// this call throws exception 