Пример #1
0
        private void button2_click(object sender, EventArgs e)
        {
            var subWizard = new Wizard("RightList");
            subWizard.AddStep(new SubStep1_1());

            ParentWizard.StartSubWizard(subWizard);
        }
        public void on_sub_wizard_completion_previous_wizard_resumes()
        {
            var step1 = new MockStepFactory().AStep.ThatCanMoveNext.Stub();
            var step2 = new MockStepFactory().AStep.ThatCanMoveNext.Stub();
            var step3 = new MockStepFactory().AStep.Stub();
            var mainWizard = new Wizard()
                                    .AddStep(step1)
                                    .AddStep(step2)
                                    .AddStep(step3);

            var step1_1 = new MockStepFactory().AStep.ThatCanMoveNext.Stub();
            var subWizard = new Wizard()
                                    .AddStep(step1_1);

            var view = new MockViewFactory().AView.Mock();
            var controller = new WizardController(view.Object);

            controller.Start(mainWizard);
            view.Raise(v => v.MovedNext += null, EventArgs.Empty);
            Assert.AreEqual(step2, controller.CurrentStep, "At Step 2 before starting Sub Wizard");

            controller.Start(subWizard);
            Assert.AreEqual(step1_1, controller.CurrentStep, "In Sub Wizard after starting Sub Wizard");

            view.Raise(v => v.MovedNext += null, EventArgs.Empty);
            Assert.AreEqual(step2, controller.CurrentStep, "At Step 2 after ending Sub Wizard");
        }
Пример #3
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            var createCourse = new Wizard()
                .AddStep(new CreateCourse());

            StartSubWizard(createCourse);
        }
Пример #4
0
        private void button1_click(object sender, EventArgs e)
        {
            var subWizard = new Wizard("SubWizard");
                subWizard.AddStep(new SubStep1_1());

            StartSubWizard(subWizard);
        }
Пример #5
0
        public void GivenAOneStepWizard_OnExit_WizardIsNotInProcess()
        {
            var step = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step);

            wizard.Start();
            wizard.Exit();
            Assert.That(wizard.IsInProcess, Is.False);
        }
Пример #6
0
        public void GivenAOneStepWizard_OnMoveNext_WizardIsFinished()
        {
            var step = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step);

            wizard.Start();
            wizard.MoveNext();
            Assert.That(wizard.IsInProcess, Is.False);
        }
Пример #7
0
        public void Start(Wizard wizard)
        {
            if (_activeWizard != null)
                _wizardStack.Push(_activeWizard);

            _activeWizard = wizard;
            _activeWizard.StartWith(this);

            ShowWizard(_view);
        }
Пример #8
0
        public void can_not_move_next_on_an_unstarted_wizard()
        {
            var step1 = new WizardStep();

            _wizard = new Wizard()
                .AddStep(step1);

            _wizard.MoveNext();
            Assert.AreEqual(true, _wizard.IsInProcess);
            Assert.AreEqual(step1, _wizard.CurrentStep);
        }
Пример #9
0
        public Form1()
        {
            InitializeComponent();

            var wizard = new Wizard();
            wizard.AddStep(new Step1())
                  .AddStep(new Step2());

            var controller = new WizardController(wizardView);
            controller.Start(wizard);
        }
Пример #10
0
        public void GiveAnUnstartedWizard_OnStarting_TheFirstStepIsSentToTheView()
        {
            var view = new MockViewFactory().AView.Mock();
            var controller = new WizardController(view.Object);

            var step = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step);

            controller.Start(wizard);
            view.Verify(m => m.ShowStep(step));
        }
Пример #11
0
        public void GivenAStartedWizard_OnFinish_NoStepIsSentToTheView()
        {
            var view = new MockViewFactory().AView.Mock();
            var controller = new WizardController(view.Object);

            var step = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step);

            controller.Start(wizard);
            view.Raise(v => v.MovedNext += null, EventArgs.Empty);
            view.Verify(m => m.ShowStep(step), Times.AtMostOnce());
        }
Пример #12
0
        private void OnCancel(object sender, EventArgs e)
        {
            var view = sender as IWizardView;
            if (view == null) return;

            _activeWizard.Exit();
            if (_wizardStack.Count > 0)
            {
                _activeWizard = _wizardStack.Pop();
                ShowWizard(view);
            }
            else
                view.Unload(_activeWizard.Args);
        }
Пример #13
0
        public void GivenAStartedWizard_OnMoveNext_TheSecondStepIsSentToTheView()
        {
            var view = new MockViewFactory().AView.Mock();
            var controller = new WizardController(view.Object);

            var step1 = new WizardStep();
            var step2 = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step1)
                    .AddStep(step2);

            controller.Start(wizard);
            view.Raise(v => v.MovedNext += null, EventArgs.Empty);
            view.Verify(m => m.ShowStep(step2));
        }
Пример #14
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var argsForStep2 = new Args();
            argsForStep2.AddOrReplace("arg1", "abcdef");
            argsForStep2.AddOrReplace("arg2", "bcdef");
            argsForStep2.AddOrReplace("arg3", "cdef");
            argsForStep2.AddOrReplace("arg4", "efghi");
            argsForStep2.AddOrReplace("arg5", "fghijkl");

            IWizardView view = new SimpleWizardView();
            var controller = new WizardController(view);

            var wizard = new Wizard();
            wizard.AddStep(new Step1(argsForStep2))
                  .AddStep(new Step2(argsForStep2));
            controller.Start(wizard);

            Application.Run(view as Form);
        }
Пример #15
0
        private void OnMovedNext(object sender, EventArgs e)
        {
            var view = sender as IWizardView;
            if (view == null) return;

            _activeWizard.MoveNext();

            if (!_activeWizard.IsInProcess)
            {
                var resumeFromTitle = _activeWizard.Title;
                var returnArgs = _activeWizard.Args;

                if (_wizardStack.Count > 0)
                {
                    _activeWizard = _wizardStack.Pop();
                    CurrentStep.ResumeFrom(resumeFromTitle, returnArgs);
                }
                else
                    view.Unload(_activeWizard.Args);
            }

            if (_activeWizard.IsInProcess)
                ShowWizard(view);
        }
Пример #16
0
 public void empty_wizard_throws_an_exception_on_start()
 {
     _wizard = new Wizard();
     _wizard.Start();
     _wizard.MoveNext();
 }
Пример #17
0
 public void StartSubWizard(Wizard subWizard)
 {
     _controller.Start(subWizard);
 }
Пример #18
0
 public void StartSubWizard(Wizard subWizard)
 {
     ParentWizard.StartSubWizard(subWizard);
 }
Пример #19
0
        public void GivenATwoStepWizard_OnStarting_WizardIsNotOnLastStep()
        {
            var step1 = new WizardStep();
            var step2 = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step1)
                    .AddStep(step2);

            wizard.Start();
            Assert.That(wizard.IsLastStep(), Is.False);
        }
Пример #20
0
        public void GivenATwoStepWizard_OnMovingToSecondStep_WizardIsNotOnFirstStep()
        {
            var step1 = new WizardStep();
            var step2 = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step1)
                    .AddStep(step2);

            wizard.Start();
            wizard.MoveNext();
            Assert.That(wizard.IsFirstStep(),Is.False);
        }
Пример #21
0
 public void new_wizard_is_not_started()
 {
     _wizard = new Wizard();
     Assert.AreEqual(false, _wizard.IsInProcess);
 }
Пример #22
0
 public void move_previous_unstarted_wizard_throws_exception()
 {
     _wizard = new Wizard();
     _wizard.AddStep(new WizardStep());
     _wizard.MovePrevious();
 }
Пример #23
0
        public void GivenAOneStepWizard_OnStarting_WizardIsOnFirstStep()
        {
            var step = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step);

            wizard.Start();
            Assert.That(wizard.IsFirstStep());
        }
Пример #24
0
        public void GivenAOneStepWizard_OnMovePrevious_WizardIsCancelled()
        {
            var step = new WizardStep();
            var wizard = new Wizard()
                    .AddStep(step);

            wizard.Start();
            wizard.MovePrevious();
            Assert.That(wizard.IsInProcess, Is.False);
        }
Пример #25
0
 public void a_wizard_can_have_a_title()
 {
     _wizard = new Wizard("Any Title");
     Assert.AreEqual("Any Title", _wizard.Title);
 }
Пример #26
0
 public void a_wizard_does_not_have_to_have_a_title()
 {
     _wizard = new Wizard();
     Assert.AreEqual("", _wizard.Title);
 }
Пример #27
0
 public void empty_wizard_throws_exception_on_move_next()
 {
     _wizard = new Wizard();
     _wizard.MoveNext();
 }