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_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); } }