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 TestHeaderLabelEnabledWhen_WizardStepTextSet() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); SetWizardControlSize(wizardControl); wizardControl.Start(); //--------------Assert PreConditions---------------- Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); //Assert.IsFalse(wizardControl.HeadingLabel.Visible); //Assert.AreEqual(wizardControl.Height - wizardControl.NextButton.Height - 62, wizardControl.WizardStepPanel.Height); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Test Result ----------------------- IWizardStep currentStep = wizardController.GetCurrentStep(); Assert.AreEqual("ControlForStep2", wizardControl.CurrentControl.Name); Assert.AreSame(currentStep, wizardControl.CurrentControl); Assert.IsTrue(((IWizardStepStub)currentStep).IsInitialised); //Assert.IsTrue(wizardControl.HeadingLabel.Visible); //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); }
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 TestStart() { //Setup ----------------------------------------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); //Execute --------------------------------------------------- wizardControl.Start(); //Assert Results -------------------------------------------- Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); Assert.AreEqual(wizardController.ControlForStep1.Name, wizardControl.CurrentControl.Name); }
public void Test_NextPreviousIn_theCorrectOrder() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); //---------------Test Result ----------------------- Assert.Less(wizardControl.NextButton.Left, wizardControl.PreviousButton.Left); //---------------Tear Down ------------------------- }
public void TestCancelFiresEvent() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); //--------------Assert PreConditions---------------- Assert.IsFalse(wizardController.CancelWizardWasCalled); //---------------Execute Test ---------------------- wizardControl.CancelButton.PerformClick(); //---------------Test Result ----------------------- Assert.IsTrue(wizardController.CancelWizardWasCalled); }
public void Test_SetWizardController_CallsStart() { //Setup ---------------------------------------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(_controller); wizardControl.Width = 300; //Execute --------------------------------------------------- wizardControl.WizardController = wizardController; //Assert Results -------------------------------------------- Assert.AreEqual("ControlForStep1", wizardControl.CurrentControl.Name); Assert.AreEqual(wizardController.ControlForStep1.Name, wizardControl.CurrentControl.Name); Assert.AreEqual(0, wizardControl.PreviousButton.TabIndex); Assert.AreEqual(1, wizardControl.NextButton.TabIndex); }
public void Test_CancelButton_WhenCanCancelTrue_ShouldBeEnabled() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.AllowCancel = true; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsTrue(wizardController.CanCancel()); //---------------Execute Test ---------------------- var cancelEnabled = wizardControl.CancelButton.Enabled; //---------------Assert result ----------------------- Assert.IsTrue(cancelEnabled, "Cancel should b enabled"); }
public void Test_FinishButton_WhenAtLastStep_ShouldBeEnabled() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep3.AllowFinish = true; wizardControl.Start(); wizardControl.Next(); wizardControl.Next(); //---------------Assert Preconditions ---------------------- Assert.IsTrue(wizardController.IsLastStep()); //---------------Execute Test ---------------------- wizardControl.Finish(); //---------------Test Result ----------------------- Assert.IsTrue(wizardControl.FinishButton.Enabled); }
public void Test_FinishButton_WhenCanFinishTrue_ShouldBeEnabled() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep2.AllowFinish = true; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsTrue(wizardController.ControlForStep2.AllowFinish); Assert.IsTrue(wizardController.ControlForStep2.CanFinish()); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Assert result ----------------------- Assert.AreSame(wizardControl.CurrentControl, wizardController.ControlForStep2); Assert.IsTrue(wizardControl.FinishButton.Enabled, "Finish button should be enabled"); }
public void Test_NextClickAtLastStep_WhenCanMoveOnfalse_DoesNotFinish() { //---------------Set up test pack------------------- IWizardControllerSpy controller = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller);// new WizardControl(_controller); controller.ControlForStep1.AllowMoveOn = true; controller.ControlForStep2.AllowMoveOn = false; wizardControl.Start(); wizardControl.NextButton.PerformClick(); //---------------Execute Test ---------------------- wizardControl.NextButton.PerformClick(); //---------------Test Result ----------------------- // Finish should not have been called because CanMoveOn on step two is returning false and should prevent // the wizard from finishing. Assert.IsFalse(controller.FinishWizardWasCalled); }
public void Test_PreviousButtonDisabledIfCanMoveBackFalse() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep2.AllowMoveBack = false; wizardControl.Start(); //---------------Assert Preconditions ---------------------- Assert.IsFalse(wizardController.ControlForStep2.CanMoveBack()); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Assert result ----------------------- Assert.AreSame(wizardControl.CurrentControl, wizardController.ControlForStep2); Assert.IsFalse(((IWizardStepStub)wizardControl.CurrentControl).AllowMoveBack); Assert.IsFalse(wizardControl.PreviousButton.Enabled); }
public void TestFinishButton_WhenClicked_WhenCanMoveOn_ShouldFireFinishEvent() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.AllowCanMoveOn = true; wizardControl.Start(); //--------------Assert PreConditions---------------- Assert.IsFalse(wizardController.FinishWizardWasCalled); string message; Assert.IsTrue(wizardController.CanMoveOn(out message)); //---------------Execute Test ---------------------- wizardControl.Finish(); //---------------Test Result ----------------------- Assert.IsTrue(wizardController.FinishWizardWasCalled, "Finish should be called"); }
public void Test_NextButton_WhenAtLastStep_ShouldBeDisabled() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardController.ControlForStep3.AllowFinish = true; wizardControl.Start(); wizardControl.Next(); //---------------Assert Preconditions ---------------------- Assert.IsFalse(wizardController.IsLastStep(), "Should not be last step"); Assert.IsTrue(wizardControl.NextButton.Enabled, "If this is not the last step should be enabled"); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Test Result ----------------------- Assert.IsTrue(wizardController.IsLastStep(), "Should be last step"); Assert.IsFalse(wizardControl.NextButton.Enabled, "Should disable next button and enable Finish button at last step"); Assert.IsTrue(wizardControl.FinishButton.Enabled, "Should enable Finish button at last step"); }
public void Test_Next_ShouldCallMoveNext() { //---------------Set up test pack------------------- IWizardControllerSpy controller = CreateWizardControllerStub(); var step1 = controller.ControlForStep1; step1.AllowMoveOn = true; IWizardControl wizardControl = GetControlFactory().CreateWizardControl(controller); controller.GetFirstStep(); //---------------Assert Precondition---------------- Assert.AreEqual(3, controller.StepCount); Assert.IsFalse(step1.MoveOnWasCalled); Assert.AreSame(step1, controller.GetCurrentStep()); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Test Result ----------------------- Assert.IsTrue(step1.MoveOnWasCalled); }
public void Test_SetStepResizesControl() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); wizardControl.Start(); wizardController.ControlForStep2.Width = 10; //--------------Assert PreConditions---------------- string msg; Assert.IsTrue(wizardController.CanMoveOn(out msg)); //---------------Execute Test ---------------------- wizardControl.Next(); //---------------Test Result ----------------------- Assert.AreEqual(wizardControl.Width - WizardControl.PADDING * 2, wizardController.ControlForStep2.Width); }
public void TestFinish_WhenNotCanMoveOn_ShouldNotFireFinishEventAndShouldPostMessage() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); string message; wizardController.AllowCanMoveOn = false; wizardControl.Start(); //--------------Assert PreConditions---------------- Assert.IsFalse(wizardController.FinishWizardWasCalled); Assert.IsFalse(wizardController.CanMoveOn(out message)); message = ""; //---------------Execute Test ---------------------- wizardControl.MessagePosted += delegate(string messagePosted) { message = messagePosted; }; wizardControl.Finish(); //---------------Test Result ----------------------- Assert.IsFalse(wizardController.FinishWizardWasCalled, "Finish should be called"); Assert.AreEqual("AllowCanMoveOnFalse", message); }
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); }
public void TestConstructWizardControl() { //---------------Set up test pack------------------- IWizardControllerSpy wizardController = CreateWizardControllerStub(); //---------------Execute Test ---------------------- IWizardControl wizardControl = GetControlFactory().CreateWizardControl(wizardController); SetWizardControlSize(wizardControl); //---------------Test Result ----------------------- Assert.IsNotNull(wizardControl.PreviousButton); Assert.IsNotNull(wizardControl.NextButton); Assert.IsNotNull(wizardControl.CancelButton); Assert.IsNotNull(wizardControl.FinishButton); Assert.Less(wizardControl.FinishButton.Left, wizardControl.CancelButton.Left); Assert.Less(wizardControl.NextButton.Left, wizardControl.FinishButton.Left); Assert.Less(wizardControl.PreviousButton.Left, wizardControl.NextButton.Left); Assert.Less(wizardControl.NextButton.Left, wizardControl.CancelButton.Left); Assert.AreEqual(0, wizardControl.PreviousButton.TabIndex); Assert.AreEqual(1, wizardControl.NextButton.TabIndex); Assert.AreEqual(wizardControl.Height, wizardControl.NextButton.Height + wizardControl.WizardStepPanel.Height + 10); }
public void SetupFixture() { _controller = CreateWizardControllerStub(); _wizardControl = GetControlFactory().CreateWizardControl(_controller);// new WizardControl(_controller); }