public void RunWorkerAsync_SubscribeToOnRunWorkerCompletedEventAndWorkCancelsOperation_InvokesOnRunWorkerCompletedWithCancelSetToTrue() { // arrange WorkerTester tester = new WorkerTester(InitializeWorker()); // act WorkerTesterResult result = tester.RunWorkerAsyncWithCancel(null); // assert Assert.IsTrue(result.OnRunWorkerComplatedEventArgs.Cancelled); }
public void RunWorkerAsync_SubscribeToOnRunWorkerCompletedEventAndRunWorkerWithoutArgument_InvokesOnRunWorkerCompletedWhenTaskFinishes() { // arrange WorkerTester tester = new WorkerTester(InitializeWorker()); // act WorkerTesterResult result = tester.RunWorkerAsync(); // assert Assert.IsTrue(result.IsRunWorkerCompletedCalled); }
public void RunWorkerAsync_SubscribeToOnRunWorkerCompletedEventAndWorkThrowsException_InvokesOnRunWorkerCompletedWithExceptionDetails() { // arrange WorkerTester tester = new WorkerTester(InitializeWorker()); // act WorkerTesterResult result = tester.RunWorkerAsyncWithException(null); // assert Assert.That(result.OnRunWorkerComplatedEventArgs.Error, Is.InstanceOf <Exception>()); }
public void RunWorkerAsync_SubscribeToOnDoWorkEventAndRunWorker_SetsCancellationPendingToFalse() { // arrange WorkerTester tester = new WorkerTester(InitializeWorker()); // act WorkerTesterResult result = tester.RunWorkerAsync(); // assert Assert.IsFalse(result.CancellationPending); }
public void RunWorkerAsync_SubscribeToOnDoWorkEvent_WhenEventIsFiredWorkerIsBusy() { // arrange WorkerTester tester = new WorkerTester(InitializeWorker()); // act WorkerTesterResult result = tester.RunWorkerAsync(); // assert Assert.IsTrue(result.IsBusy); }
public void RunWorkerAsync_SubscribeToOnDoWorkEventAndRunWorkerWithArgument_InvokesOnDoWorkEventWithSuppliedArgument(object expectedArgument) { // arrange WorkerTester tester = new WorkerTester(InitializeWorker()); // act WorkerTesterResult result = tester.RunWorkerAsync(expectedArgument); // assert Assert.AreEqual(expectedArgument, result.DoWorkArgument); }
public void RunWorkerAsync_SubscribeToOnDoWorkEventAndRunWorkerWithoutArgument_InvokesOnDoWorkEvent() { // arrange WorkerTester tester = new WorkerTester(InitializeWorker()); // act WorkerTesterResult result = tester.RunWorkerAsync(); // assert Assert.IsTrue(result.IsDoWorkCalled); }
public WorkerTesterResult RunWorkerAsyncWithException(object argument) { WorkerTesterResult result = new WorkerTesterResult(); worker.OnDoWork += (sender, e) => { throw new Exception("OnDoWork exception"); }; worker.OnRunWorkerCompleted += (sender, e) => { result.OnRunWorkerComplatedEventArgs = e; }; worker.RunWorkerAsync(argument); return(result); }
public WorkerTesterResult RunWorkerAsyncWithCancel(object argument) { WorkerTesterResult result = new WorkerTesterResult(); worker.OnDoWork += (sender, e) => { e.Cancel = true; }; worker.OnRunWorkerCompleted += (sender, e) => { result.OnRunWorkerComplatedEventArgs = e; }; worker.RunWorkerAsync(argument); return(result); }
public WorkerTesterResult RunWorkerAsync(object argument) { WorkerTesterResult result = new WorkerTesterResult(); worker.OnDoWork += (sender, e) => { result.IsDoWorkCalled = true; result.DoWorkArgument = e.Argument; result.IsBusy = worker.IsBusy; result.CancellationPending = worker.CancellationPending; }; worker.OnRunWorkerCompleted += (sender, e) => { result.IsRunWorkerCompletedCalled = true; }; worker.RunWorkerAsync(argument); return(result); }
public WorkerTesterResult RunWorkerAsyncWithException(object argument) { WorkerTesterResult result = new WorkerTesterResult(); worker.OnDoWork += (sender, e) => { throw new Exception("OnDoWork exception"); }; worker.OnRunWorkerCompleted += (sender, e) => { result.OnRunWorkerComplatedEventArgs = e; }; worker.RunWorkerAsync(argument); return result; }
public WorkerTesterResult RunWorkerAsyncWithCancel(object argument) { WorkerTesterResult result = new WorkerTesterResult(); worker.OnDoWork += (sender, e) => { e.Cancel = true; }; worker.OnRunWorkerCompleted += (sender, e) => { result.OnRunWorkerComplatedEventArgs = e; }; worker.RunWorkerAsync(argument); return result; }
public WorkerTesterResult RunWorkerAsync(object argument) { WorkerTesterResult result = new WorkerTesterResult(); worker.OnDoWork += (sender, e) => { result.IsDoWorkCalled = true; result.DoWorkArgument = e.Argument; result.IsBusy = worker.IsBusy; result.CancellationPending = worker.CancellationPending; }; worker.OnRunWorkerCompleted += (sender, e) => { result.IsRunWorkerCompletedCalled = true; }; worker.RunWorkerAsync(argument); return result; }