public void Test_Previous_WhenStep2_ShouldReturnStep1() { //Setup ---------------------------------------------------- _wizardControl.Next(); //Execute --------------------------------------------------- _wizardControl.Previous(); //Assert Results -------------------------------------------- Assert.AreSame(_controller.ControlForStep1, _wizardControl.CurrentControl); }
public void Test_PreviousButtonDisabledIfCanMoveBackFalse_FromPreviousTep() { //TODO: setup with 3 steps set step 2 allow move back false //and go next next next previous and then ensure that canMoveBack false //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); wizardController.ForTestingAddWizardStep(CreateWizardStepStub()); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep2.AllowMoveBack = false; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsFalse(wizardController.ControlForStep2.CanMoveBack()); //---------------Execute Test ---------------------- wizardControl.Next(); wizardControl.Next(); wizardControl.Previous(); //---------------Assert result ----------------------- Assert.AreSame(wizardControl.CurrentControl, wizardController.ControlForStep2); Assert.IsFalse(((IWizardStepStub)wizardControl.CurrentControl).AllowMoveBack); Assert.IsFalse(wizardControl.PreviousButton.Enabled); }
public void Test_Previous_WhenLastStep_WhenNotCanFinishOnSecondStep_ShouldEnableNextButtonAndDisableFinishButton() { //---------------Set up test pack------------------- IWizardControllerSpy controller = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller); var step1 = controller.ControlForStep1; var step2 = controller.ControlForStep2; var step3 = controller.ControlForStep3; step1.AllowMoveOn = true; step3.AllowMoveBack = true; step2.AllowFinish = false; controller.GetFirstStep(); MoveToLastStep(wizardControl); //---------------Assert Precondition---------------- Assert.IsTrue(controller.CanMoveBack()); Assert.AreSame(step3, controller.GetCurrentStep()); Assert.IsFalse(step2.CanFinish()); Assert.IsTrue(controller.IsLastStep(), "Should be last step"); Assert.IsTrue(wizardControl.FinishButton.Enabled, "Last step so finish enabled"); Assert.IsFalse(wizardControl.NextButton.Enabled, "last step so next disabled"); //---------------Execute Test ---------------------- wizardControl.Previous(); //---------------Test Result ----------------------- Assert.IsFalse(controller.IsLastStep(), "Should be last step"); Assert.AreSame(step2, controller.GetCurrentStep()); Assert.IsFalse(wizardControl.FinishButton.Enabled, "Not Last step and CanFinish False so finish disabled"); Assert.IsTrue(wizardControl.NextButton.Enabled, "Not last step so Next Enabled"); }
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 TestHeaderLabelDisabledWhen_WizardStepTextSetBackToNull() { // this test doesn't do what it says?! //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); SetWizardControlSize(wizardControl); wizardControl.Start(); wizardControl.Next(); //--------------Assert PreConditions---------------- wizardController.GetCurrentStep(); Assert.AreEqual("ControlForStep2", wizardControl.CurrentControl.Name); //Assert.IsTrue(wizardControl.HeadingLabel.Visible); //removed the label and am now putting the header on the form // due to problems with giz hiding the some wizard controls that where double clicked //Assert.IsTrue(wizardControl.HeadingLabel.Text.Length > 0); //Assert.AreEqual(step.HeaderText, wizardControl.HeadingLabel.Text); //Assert.AreEqual(wizardControl.Height - wizardControl.NextButton.Height - 62 - wizardControl.HeadingLabel.Height, wizardControl.WizardStepPanel.Height); //---------------Execute Test ---------------------- wizardControl.Previous(); //---------------Test Result ----------------------- wizardController.GetCurrentStep(); Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); //Assert.IsFalse(wizardControl.HeadingLabel.Visible); //Assert.IsFalse(wizardControl.HeadingLabel.Text.Length > 0); //Assert.AreEqual(step.HeaderText, wizardControl.HeadingLabel.Text); //Assert.AreEqual(wizardControl.Height - wizardControl.NextButton.Height - 62, wizardControl.WizardStepPanel.Height); }
public void Test_Previous_ShouldCallWizardControllerUndo() { //---------------Set up test pack------------------- IWizardController controller = MockRepository.GenerateMock <IWizardController>(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller); string message; controller.Stub(wizardController => wizardController.CanMoveOn(out message)).Return(true); controller.Stub(controller1 => controller1.GetPreviousStep()).Return(CreateWizardStepStub()); //---------------Assert Precondition---------------- Assert.IsTrue(controller.CanMoveOn(out message)); controller.AssertWasNotCalled(cntrler => cntrler.UndoCompleteCurrentStep()); //---------------Execute Test ---------------------- wizardControl.Previous(); //---------------Test Result ----------------------- controller.AssertWasCalled(cntrler => cntrler.UndoCompleteCurrentStep()); }
public void Test_FinishButton_WhenCanFinishFalse_WhenFromPreviousStep_ShouldBeDisabled() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); wizardController.ForTestingAddWizardStep(CreateWizardStepStub()); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep2.AllowFinish = false; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsFalse(wizardController.ControlForStep2.AllowFinish); Assert.IsFalse(wizardController.ControlForStep2.CanFinish()); //---------------Execute Test ---------------------- wizardControl.Next(); wizardControl.Next(); wizardControl.Previous(); //---------------Assert result ----------------------- Assert.AreSame(wizardControl.CurrentControl, wizardController.ControlForStep2); Assert.IsFalse(wizardControl.FinishButton.Enabled); }