public void ProgressStepViewModel_AllPublicPropertiesNotifyChanges() { ProgressStepViewModel model = new ProgressStepViewModel(); ViewModelVerifier.RunVerificationTest<ProgressStepViewModel, string>(model, "DisplayText", "value1", "value2"); ViewModelVerifier.RunVerificationTest<ProgressStepViewModel, StepExecutionState>(model, "ExecutionState", StepExecutionState.Cancelled, StepExecutionState.Failed); ViewModelVerifier.RunVerificationTest<ProgressStepViewModel, string>(model, "ProgressDetailText", null, string.Empty); }
public void ProgressControllerViewModel_AllPublicPropertiesNotifyChanges() { ProgressControllerViewModel model = new ProgressControllerViewModel(); ProgressStepViewModel step = new ProgressStepViewModel(); model.Steps.Add(step); ViewModelVerifier.RunVerificationTest<ProgressControllerViewModel, string>(model, "Title", "value1", "value2"); ViewModelVerifier.RunVerificationTest<ProgressControllerViewModel, ProgressStepViewModel>(model, "Current", null, step); ViewModelVerifier.RunVerificationTest<ProgressControllerViewModel, bool>(model, "Cancellable", true, false); ViewModelVerifier.RunVerificationTest<ProgressControllerViewModel, ICommand>(model, "CancelCommand", null, new RelayCommand((s) => { })); }
private void InitializeStepViewModels() { // Although the steps should not change we take a snapshot for safety this.steps = this.progressEvents.Steps.ToArray(); // Create execution groups for all the impacting steps, each group will have one visible step IEnumerable<ExecutionGroup> executionGroups = GroupToExecutionUnits(this.ProgressImpactingSteps); foreach (ExecutionGroup group in executionGroups) { ProgressStepViewModel stepViewModel = new ProgressStepViewModel(); InitializeStep(stepViewModel, group); this.viewModelRoot.Steps.Add(stepViewModel); // Update mappings this.viewModelToExecutionGroupMapping[stepViewModel] = group; foreach (IProgressStep step in group.Steps) { this.progressStepToViewModelMapping[step] = stepViewModel; } } }
/// <summary> /// Sets the initial state of a <see cref="ProgressStepViewModel"/> /// </summary> /// <param name="viewModel">The <see cref="ProgressStepViewModel"/> instance to initialize</param> /// <param name="group">The logical group which the <see cref="ProgressStepViewModel"/> represent</param> private static void InitializeStep(ProgressStepViewModel viewModel, ExecutionGroup group) { ThreadHelper.ThrowIfNotOnUIThread(); IProgressStep first = group.Steps.First(); IProgressStep nonHiddenStep = group.Steps.FirstOrDefault(s => !s.Hidden); Debug.Assert(nonHiddenStep != null, "The execution group has no visible steps"); viewModel.DisplayText = nonHiddenStep.DisplayText; viewModel.ExecutionState = first.ExecutionState; viewModel.Progress.SetUpperBoundLimitedValue(first.Progress); viewModel.ProgressDetailText = first.ProgressDetailText; viewModel.Progress.IsIndeterminate = group.Steps.Any(s => s.Indeterminate); }
private static void VerifyProgress(IProgressVisualizer visualizer, double mainProgress, ProgressStepViewModel current, double subProgress) { Assert.AreEqual(mainProgress, visualizer.ViewModel.MainProgress.Value, FloatingPointError, "Unexpected main progress"); if (current == null) { Assert.IsNull(visualizer.ViewModel.Current, "Not expecting any current step"); } else { Assert.AreSame(current, visualizer.ViewModel.Current, "Unexpected current step"); if (double.IsNaN(subProgress)) { Assert.IsTrue(double.IsNaN(current.Progress.Value), "Unexpected sub progress"); } else { Assert.AreEqual(subProgress, current.Progress.Value, FloatingPointError, "Unexpected sub progress"); } } }
private static void VerifyStep(ProgressStepViewModel vm, IProgressStep step) { Assert.AreEqual(step.DisplayText, vm.DisplayText, "DisplayText doesn't match"); Assert.AreEqual(step.ExecutionState, vm.ExecutionState, "ExecutionState doesn't match"); Assert.AreEqual(step.Progress, vm.Progress.Value, "Progress doesn't match"); Assert.AreEqual(step.ProgressDetailText, vm.ProgressDetailText, "ProgressDisplayText doesn't match"); Assert.AreEqual(step.Indeterminate, vm.Progress.IsIndeterminate, "Indeterminate doesn't match"); }