public void Test_CallFinish_WhenAtLastStep_ShouldRaiseEvent()
        {
            //---------------Set up test pack-------------------
            bool finished = false;

            _wizardControl.Finished += delegate { finished = true; };
            //---------------Execute Test ----------------------
            _wizardControl.Next();
            _wizardControl.Finish();
            //---------------Test Result -----------------------
            Assert.IsTrue(_controller.FinishWizardWasCalled);
            Assert.IsTrue(finished);
        }
        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 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 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);
        }