public void LifeCycle() { // Arrange var progressHandler = new StatusBarDownloadProgressHandler(dummyStatusBar, dummyInstaller, logger); // 1. Initial request dummyInstaller.SimulateProgressChanged(new InstallationProgressChangedEventArgs(0, 1000)); dummyStatusBar.CheckLastCallWasSetupCall(0, 1000); // 2. Progress updates dummyInstaller.SimulateProgressChanged(new InstallationProgressChangedEventArgs(100, 1000)); dummyStatusBar.CheckLastCallWasInProgressCall(100, 1000); // 3. Cleanup - reset the statusbar dummyInstaller.SimulateInstallFinished(new System.ComponentModel.AsyncCompletedEventArgs(null, false, null)); dummyStatusBar.CheckLastCallWasCleanup(); dummyStatusBar.ProgressCallCount.Should().Be(3); dummyInstaller.AssertNoEventHandlersRegistered(); // 4. Dispose progressHandler.Dispose(); dummyStatusBar.ProgressCallCount.Should().Be(3); // progress should not be called since already cleaned up dummyInstaller.AssertNoEventHandlersRegistered(); }
public void LifeCycle() { // Arrange var progressHandler = new StatusBarReanalysisProgressHandler(dummyStatusBar, logger); // 1. Initial request ReportProgress(progressHandler, CancellableJobRunner.RunnerState.Running, 0, 2); dummyStatusBar.CheckLastCallWasSetupCall(0, 2); // 2a. Progress updates ReportProgress(progressHandler, CancellableJobRunner.RunnerState.Running, 1, 2); dummyStatusBar.CheckLastCallWasInProgressCall(1, 2); // 2b. Progress updates ReportProgress(progressHandler, CancellableJobRunner.RunnerState.Running, 2, 2); dummyStatusBar.CheckLastCallWasInProgressCall(2, 2); // 3. Finished -> clean up and reset the statusbar ReportProgress(progressHandler, CancellableJobRunner.RunnerState.Finished, 111, 222); dummyStatusBar.CheckLastCallWasCleanup(); dummyStatusBar.ProgressCallCount.Should().Be(4); // 4. Dispose - should be a no-op in this case progressHandler.Dispose(); dummyStatusBar.ProgressCallCount.Should().Be(4); // status bar should not be called since already cleaned up }