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_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_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 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_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_SubscribeToOnDoWorkEvent_WhenEventIsFiredWorkerIsBusy()
        {
            // arrange
            WorkerTester tester = new WorkerTester(InitializeWorker());

            // act
            WorkerTesterResult result = tester.RunWorkerAsync();

            // assert
            Assert.IsTrue(result.IsBusy);
        }
        public void RunWorkerAsync_SubscribeToOnDoWorkEventAndRunWorker_SetsCancellationPendingToFalse()
        {
            // arrange
            WorkerTester tester = new WorkerTester(InitializeWorker());

            // act
            WorkerTesterResult result = tester.RunWorkerAsync();

            // assert
            Assert.IsFalse(result.CancellationPending);
        }
        public void RunWorkerAsync_SubscribeToOnDoWorkEventAndRunWorkerWithoutArgument_InvokesOnDoWorkEvent()
        {
            // arrange
            WorkerTester tester = new WorkerTester(InitializeWorker());

            // act
            WorkerTesterResult result = tester.RunWorkerAsync();

            // assert
            Assert.IsTrue(result.IsDoWorkCalled);
        }
        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);
        }