GetFirstStep() public method

Returns the First Step of the Wizard and sets the current step to that step.
public GetFirstStep ( ) : IWizardStep
return IWizardStep
 public void Test_Previous_ShouldCallUndoMoveOnForPreviousStep()
 {
     //---------------Set up test pack-------------------
     WizardController controller = new WizardController();
     IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller);
     var step1 = CreateWizardStepStub();
     controller.AddStep(step1);
     var step2 = CreateWizardStepStub();
     controller.AddStep(step2);
     step1.AllowMoveOn = true;
     step2.AllowMoveBack = true;
     controller.GetFirstStep();
     controller.GetNextStep();
     //---------------Assert Precondition----------------
     Assert.IsTrue(controller.CanMoveBack());
     Assert.AreSame(step2, controller.GetCurrentStep());
     Assert.IsFalse(step1.UndoMoveOnWasCalled);
     Assert.IsFalse(step2.UndoMoveOnWasCalled);
     //---------------Execute Test ----------------------
     wizardControl.Previous();
     //---------------Test Result -----------------------
     Assert.AreSame(step1, controller.GetCurrentStep());
     Assert.IsTrue(step1.UndoMoveOnWasCalled);
     Assert.IsFalse(step2.UndoMoveOnWasCalled);
 }
 public void Test_UndoCurrentStep_ShouldCallStepMoveBack()
 {
     //---------------Set up test pack-------------------
     WizardController wizardController = new WizardController();
     var step1 = MockRepository.GenerateMock<IWizardStep>();
     wizardController.AddStep(step1);
     wizardController.GetFirstStep();
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, wizardController.StepCount);
     step1.AssertWasNotCalled(step => step.UndoMoveOn());
     Assert.AreSame(step1, wizardController.GetCurrentStep());
     //---------------Execute Test ----------------------
     wizardController.UndoCompleteCurrentStep();
     //---------------Test Result -----------------------
     step1.AssertWasCalled(wizardStep => wizardStep.UndoMoveOn());
 }
 public void Test_CanMoveBack_WhenStepTrue_ShouldReturnTrue()
 {
     //---------------Set up test pack-------------------
     WizardController wizardController = new WizardController();
     var step1 = MockRepository.GenerateMock<IWizardStep>();
     step1.Stub(wizardStep1 => wizardStep1.CanMoveBack()).Return(true);
     wizardController.AddStep(step1);
     wizardController.GetFirstStep();
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, wizardController.StepCount);
     step1.AssertWasNotCalled(step => step.CanMoveBack());
     Assert.AreSame(step1, wizardController.GetCurrentStep());
     //---------------Execute Test ----------------------
     var canMoveBack = wizardController.CanMoveBack();
     //---------------Test Result -----------------------
     step1.AssertWasCalled(wizardStep => wizardStep.CanMoveBack());
     Assert.AreEqual(step1.CanMoveBack(), canMoveBack);
     Assert.IsTrue(canMoveBack);
 }
 public void Test_CanCancel_WhenCurrentStepCanCancelFalse_ShouldRetFalse()
 {
     //---------------Set up test pack-------------------
     WizardController wizardController = new WizardController();
     var step1 = MockRepository.GenerateStub<IWizardStep>();
     wizardController.AddStep(step1);
     wizardController.GetFirstStep();
     step1.Stub(wizardStep1 => wizardStep1.CanCancel()).Return(false);
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, wizardController.StepCount);
     Assert.AreSame(step1, wizardController.GetCurrentStep());
     Assert.IsFalse(step1.CanCancel());
     // ---------------Execute Test ----------------------
     var canFinish = ((IWizardController)wizardController).CanCancel();
     //---------------Test Result -----------------------
     Assert.IsFalse(canFinish);
 }
        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
        }
        public void Test_Finish_ShouldCallCurrentStepMoveOn()
        {
            //-----------------------Setup TestPack----------------------
            WizardController wizardController = new WizardController();

            IWizardStep step1 = MockRepository.GenerateMock<IWizardStep>();
            wizardController.AddStep(step1);

            wizardController.GetFirstStep();
            //------------------------Assert Precondition----------------
            Assert.AreSame(step1, wizardController.GetCurrentStep());
            step1.AssertWasNotCalled(step => step.MoveOn());
            //------------------------Execute----------------------------
            wizardController.Finish();
            //------------------------Verify Result ---------------------
            step1.AssertWasCalled(step => step.MoveOn());
        }
        public void Test_FinishError()
        {

            WizardController wizardController = new WizardController();

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

            wizardController.GetFirstStep();
            //------------------------Assert Precondition----------------
            Assert.AreSame(step1, wizardController.GetCurrentStep());
            Assert.IsFalse(wizardController.IsLastStep());
            Assert.IsFalse(wizardController.CanFinish(), "Should not be able to finish this");
            //------------------------Execute----------------------------
            try
            {
                wizardController.Finish();
                Assert.Fail("Expected to throw an WizardStepException");
            }
            //---------------Test Result -----------------------
            catch (WizardStepException ex)
            {
                StringAssert.Contains("Invalid call to Finish(), not at last step", ex.Message);
            }
        }
        public void Test_GetFirstStep_WhenNoFirstStepSetup()
        {
            //---------------Set up test pack-------------------
            WizardController wizardController = new WizardController();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                wizardController.GetFirstStep();
                Assert.Fail("Expected to throw an HabaneroApplicationException");
            }
                //---------------Test Result -----------------------
            catch (HabaneroApplicationException ex)
            {
                StringAssert.Contains("There was an Error when trying to access the first step of the wizard Controller", ex.Message);
                StringAssert.Contains("The wizard controller has not been set up with steps", ex.Message);
            }
            //---------------Test Result -----------------------
        }