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