public void WizardCallsPropertyChangedEventForCanGoNextStep2() { // Arrange var wizard = new AddingWizard(CurrentPluginManager); var eventFired = false; void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(wizard.CanGoForward)) { eventFired = true; } } wizard.PropertyChanged += OnPropertyChanged; wizard.Term1Step.Term1 = 10; wizard.GoForward(); // Sanity check Assert.IsFalse(wizard.CanGoForward); // Act eventFired = false; wizard.Term2Step.Term2 = 10; // Assert Assert.IsTrue(wizard.CanGoForward, "Wizard should be able to go forward"); Assert.IsTrue(eventFired, "Wizard.PropertyChanged did not fire for Wizard.CanGoForward"); // Cleanup wizard.PropertyChanged -= OnPropertyChanged; }
public void WizardCantGoTooFarBackward() { var wizard = new AddingWizard(CurrentPluginManager); Assert.AreEqual(3, wizard.Steps.Count, "Wizard does not have the correct number of steps"); var r = new Random(); var term1 = r.Next(0, 10000); var term2 = r.Next(0, 10000); // Go Forward normally (wizard.CurrentStep as AddingWizardTerm1).Term1 = term1; wizard.GoForward(); (wizard.CurrentStep as AddingWizardTerm2).Term2 = term2; wizard.GoForward(); (wizard.CurrentStep as AddingWizardResultView).ResultApproved = true; wizard.GoBack(); wizard.GoBack(); wizard.GoBack(); wizard.GoBack(); wizard.GoBack(); wizard.GoBack(); wizard.GoBack(); wizard.GoBack(); wizard.GoBack(); Assert.IsInstanceOfType(wizard.CurrentStep, typeof(AddingWizardTerm1)); }
public void TestWizardForwardWorkflow() { var wizard = new AddingWizard(CurrentPluginManager); Assert.AreEqual(3, wizard.Steps.Count, "Wizard does not have the correct number of steps"); var r = new Random(); var term1 = r.Next(0, 10000); var term2 = r.Next(0, 10000); // Go Forward Assert.AreEqual(0, wizard.CurrentStepIndex, "Wizard step index is not 0"); Assert.AreEqual("Term 1", wizard.CurrentStep.Name); Assert.IsInstanceOfType(wizard.CurrentStep, typeof(AddingWizardTerm1)); Assert.IsFalse(wizard.CanGoForward, "Shouldn't be able to proceed when step 1 is not complete"); (wizard.CurrentStep as AddingWizardTerm1).Term1 = term1; Assert.IsTrue(wizard.CanGoForward, "Should be able to proceed when step 1 is complete"); Assert.IsFalse(wizard.CanGoBack, "Shouldn't be able to go back when on the first step"); wizard.GoForward(); Assert.AreEqual(1, wizard.CurrentStepIndex, "Wizard step index is not 1"); Assert.AreEqual("Term 2", wizard.CurrentStep.Name); Assert.IsInstanceOfType(wizard.CurrentStep, typeof(AddingWizardTerm2)); Assert.IsFalse(wizard.CanGoForward, "Shouldn't be able to proceed when step 2 is not complete"); (wizard.CurrentStep as AddingWizardTerm2).Term2 = term2; Assert.IsTrue(wizard.CanGoForward, "Should be able to proceed when step 2 is complete"); Assert.IsTrue(wizard.CanGoBack, "Should be able to go back to first step"); wizard.GoForward(); Assert.AreEqual(2, wizard.CurrentStepIndex, "Wizard step index is not 2"); Assert.AreEqual("Result", wizard.CurrentStep.Name); Assert.IsInstanceOfType(wizard.CurrentStep, typeof(AddingWizardResultView)); Assert.IsFalse(wizard.CanGoForward, "Shouldn't be able to proceed when result view is not complete"); Assert.AreEqual(term1 + term2, (wizard.CurrentStep as AddingWizardResultView).Result, "Incorrect addition result"); (wizard.CurrentStep as AddingWizardResultView).ResultApproved = true; Assert.IsFalse(wizard.CanGoForward, "Shouldn't be able to proceed on final step"); Assert.IsTrue(wizard.CanGoBack, "Should be able to go back to second step"); Assert.IsTrue(wizard.IsComplete, "Wizard should be complete"); }
public void TestWizardBackwardWorkflow() { var wizard = new AddingWizard(CurrentPluginManager); Assert.AreEqual(3, wizard.Steps.Count, "Wizard does not have the correct number of steps"); var r = new Random(); var term1 = r.Next(0, 10000); var term2 = r.Next(0, 10000); // Go Forward (wizard.CurrentStep as AddingWizardTerm1).Term1 = term1; wizard.GoForward(); (wizard.CurrentStep as AddingWizardTerm2).Term2 = term2; wizard.GoForward(); (wizard.CurrentStep as AddingWizardResultView).ResultApproved = true; // We're in the third step (verified by another test) // Go Backward (wizard.CurrentStep as AddingWizardResultView).ResultApproved = false; Assert.IsFalse(wizard.CanGoForward, "Shouldn't be able to proceed on final step"); Assert.IsTrue(wizard.CanGoBack, "Going back should be unaffected by completeness"); Assert.IsFalse(wizard.IsComplete, "Wizard should no longer be complete"); wizard.GoBack(); Assert.AreEqual(1, wizard.CurrentStepIndex, "Wizard step index is not 1 after going back"); Assert.AreEqual("Term 2", wizard.CurrentStep.Name); Assert.IsInstanceOfType(wizard.CurrentStep, typeof(AddingWizardTerm2)); Assert.IsTrue(wizard.CanGoForward, "Step 2 should still be complete"); Assert.IsTrue(wizard.CanGoBack, "Should still be able to go back to first step"); wizard.GoBack(); Assert.AreEqual(0, wizard.CurrentStepIndex, "Wizard step index is not 0"); Assert.AreEqual("Term 1", wizard.CurrentStep.Name); Assert.IsInstanceOfType(wizard.CurrentStep, typeof(AddingWizardTerm1)); Assert.IsTrue(wizard.CanGoForward, "Step 1 should still be complete"); Assert.IsFalse(wizard.CanGoBack, "Should still not be able to go before first step"); }
public void WizardCallsPropertyChangedEventForCanFinish() { // Arrange var wizard = new AddingWizard(CurrentPluginManager); var eventFired = false; void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(wizard.IsComplete)) { eventFired = true; } } wizard.PropertyChanged += OnPropertyChanged; wizard.Term1Step.Term1 = 10; wizard.GoForward(); wizard.Term2Step.Term2 = 10; wizard.GoForward(); // Sanity check Assert.IsFalse(wizard.CanGoForward); Assert.IsFalse(wizard.IsComplete); // Act eventFired = false; wizard.ResultStep.ResultApproved = true; // Assert Assert.IsFalse(wizard.CanGoForward, "Wizard should not be able to go forward because it's the last step"); Assert.IsTrue(wizard.IsComplete, "Wizard should be complete."); Assert.IsTrue(eventFired, "Wizard.PropertyChanged did not fire for Wizard.IsComplete"); // Cleanup wizard.PropertyChanged -= OnPropertyChanged; }
public AddingWizardResultView(AddingWizard wizard) { Wizard = wizard; }