Habanero.Faces.Base.WizardController.Finish C# (CSharp) Method

Finish() public method

Method that is to be run when the Wizard is finished. This method should be overridden to do all persistance that is required. This raises the WizardFinished event which allows you to close forms or do anything else required.
public Finish ( ) : void
return void
        public virtual void Finish()
        {
            if (!IsLastStep() && !this.CanFinish()) throw new WizardStepException("Invalid call to Finish(), not at last step");
            var currentStep = GetCurrentStep();
            if (currentStep != null) currentStep.MoveOn();//This is to ensure that any custom code writtin into the
            // wizard step.MoveOn is executed.
            FireWizardFinishedEvent();
        }

Usage Example

        public void Test_Finish_WhenNotLast_ShouldCallCurrentStepMoveOn()
        {
            //-----------------------Setup TestPack----------------------
            WizardController wizardController = new WizardController();

            IWizardStep step1 = MockRepository.GenerateMock<IWizardStep>();
            step1.Stub(wizardStep => wizardStep.CanFinish()).Return(true);
            wizardController.AddStep(step1);
            wizardController.AddStep(step1);

            wizardController.GetFirstStep();
            //------------------------Assert Precondition----------------
            Assert.AreSame(step1, wizardController.GetCurrentStep());
            Assert.IsFalse(wizardController.IsLastStep());
            Assert.IsTrue(wizardController.CanFinish(), "Should be able to finish this");
            step1.AssertWasNotCalled(step => step.MoveOn());
            //------------------------Execute----------------------------
            wizardController.Finish();
            //------------------------Verify Result ---------------------
            step1.AssertWasCalled(step => step.MoveOn());//Should now be able to call finish even when not last step
        }
All Usage Examples Of Habanero.Faces.Base.WizardController::Finish