public void TestInitialize() { this.testServiceProvider = new ConfigurableServiceProvider(); this.testVisualizer = new ConfigurableProgressVisualizer(); this.progressEvents = new ConfigurableProgressEvents(); this.testController = new ConfigurableProgressController(this.testServiceProvider); this.testController.Events = this.progressEvents; this.threadService = new SingleThreadedTaskSchedulerService(); this.testServiceProvider.RegisterService(typeof(SVsTaskSchedulerService), this.threadService); }
public void TestInitialize() { this.testServiceProvider = new ConfigurableServiceProvider(); this.testVisualizer = new ConfigurableProgressVisualizer(); this.progressEvents = new ConfigurableProgressEvents(); this.testController = new ConfigurableProgressController(this.testServiceProvider); this.testController.Events = this.progressEvents; this.threadService = new SingleThreadedTaskSchedulerService(); this.testServiceProvider.RegisterService(typeof(SVsTaskSchedulerService), this.threadService); }
public void TestCleanup() { if (this.testSubject != null) { ((IDisposable)this.testSubject).Dispose(); this.testSubject = null; } this.testVisualizer = null; this.testServiceProvider = null; this.progressEvents = null; this.threadService = null; this.testController = null; }
public void TestCleanup() { if (this.testSubject != null) { ((IDisposable)this.testSubject).Dispose(); this.testSubject = null; } this.testVisualizer = null; this.testServiceProvider = null; this.progressEvents = null; this.threadService = null; this.testController = null; }
public void Helpers_RunOnFinished() { // Setup ConfigurableProgressEvents progressEvents = new ConfigurableProgressEvents(); ProgressControllerResult? result = null; Action<ProgressControllerResult> action = (r) => result = r; foreach (ProgressControllerResult progressResult in Enum.GetValues(typeof(ProgressControllerResult))) { result = null; Helpers.RunOnFinished(progressEvents, action); // Act progressEvents.InvokeFinished(progressResult); // Verify Assert.AreEqual(progressResult, result, "Action was not called"); progressEvents.AssertAllEventsAreUnregistered(); } }
public void Helpers_RunOnFinished() { // Arrange ConfigurableProgressEvents progressEvents = new ConfigurableProgressEvents(); ProgressControllerResult? result = null; Action <ProgressControllerResult> action = (r) => result = r; foreach (ProgressControllerResult progressResult in Enum.GetValues(typeof(ProgressControllerResult))) { result = null; Helpers.RunOnFinished(progressEvents, action); // Act progressEvents.InvokeFinished(progressResult); // Assert result.Should().Be(progressResult, "Action was not called"); progressEvents.AssertAllEventsAreUnregistered(); } }
public void RunAndVerifyExecutingStep(ConfigurableProgressEvents progressEvents, IProgressStep currentStep, int?currentVmIndex) { ProgressStepViewModel currentVM = currentVmIndex.HasValue ? this.visualizer.ViewModel.Steps[currentVmIndex.Value] : null; bool isFinalState = ProgressControllerHelper.IsFinalState(currentStep.ExecutionState) && this.IsLastStep(currentStep); // Trigger the event progressEvents.InvokeStepExecutionChanged(new StepExecutionChangedEventArgs(currentStep)); // Assert if (currentVmIndex.HasValue) { VerifyProgress(this.visualizer, this.ExpectedMainProgress, currentVM, this.ExpectedSubProgress); if (isFinalState) { this.testSubject.CurrentExecutingGroup.Should().BeNull("Not expecting any executing group"); } else { IProgressStep[] steps = this.GetAllStepsInGroup(currentStep); if (currentStep.ImpactsProgress) { steps.Should().NotBeNull("There should be at least one step in the group"); VerifyExecutionGroup(this.testSubject.CurrentExecutingGroup, steps); } else { steps.Should().BeNull("Not expecting any steps in group since not impacting, so there's no group for it"); } } } else { currentVM.Should().BeNull("Current VM should be null, since not impacts progress"); (this.testSubject.CurrentExecutingGroup == null || this.testSubject.CurrentExecutingGroup.ExecutingStep == null) .Should().BeTrue("Not expecting any changes for non impacting steps"); } }
public void RunAndVerifyExecutingStep(ConfigurableProgressEvents progressEvents, IProgressStep currentStep, int? currentVmIndex) { ProgressStepViewModel currentVM = currentVmIndex.HasValue ? this.visualizer.ViewModel.Steps[currentVmIndex.Value] : null; bool isFinalState = ProgressControllerHelper.IsFinalState(currentStep.ExecutionState) && this.IsLastStep(currentStep); // Trigger the event progressEvents.InvokeStepExecutionChanged(new StepExecutionChangedEventArgs(currentStep)); // Verify if (currentVmIndex.HasValue) { VerifyProgress(this.visualizer, this.ExpectedMainProgress, currentVM, this.ExpectedSubProgress); if (isFinalState) { Assert.IsNull(this.testSubject.CurrentExecutingGroup, "Not expecting any executing group"); } else { IProgressStep[] steps = this.GetAllStepsInGroup(currentStep); if (currentStep.ImpactsProgress) { Assert.IsNotNull(steps, "There should be at least one step in the group"); VerifyExecutionGroup(this.testSubject.CurrentExecutingGroup, steps); } else { Assert.IsNull(steps, "Not expecting any steps in group since not impacting, so there's no group for it"); } } } else { Assert.IsNull(currentVM, "Current VM should be null, since not impacts progress"); Assert.IsTrue(this.testSubject.CurrentExecutingGroup == null || this.testSubject.CurrentExecutingGroup.ExecutingStep == null, "Not expecting any changes for non impacting steps"); } }