Exemple #1
0
        public void I_can_have_2_branches_to_the_same_yield()
        {
            var branch1 = Declare.Step();
            var wf      = new StatefulWorkflow <StatefulObject>(2, gateway.Object);

            wf.Yield(1);
            wf.When(x => true).BranchTo(branch1);
            wf.Yield(2);
            wf.When(x => true).BranchTo(branch1);
            wf.Yield(3);
            wf.Define(branch1);
            wf.Yield(4);

            var transitions = wf.PossibleTransitions.ToList();

            transitions.Where(x => (int?)x.From == 1 && (int?)x.To == 4).Count().ShouldBe(1);
            transitions.Where(x => (int?)x.From == 2 && (int?)x.To == 4).Count().ShouldBe(1);
        }
Exemple #2
0
        public void Operations_work_when_using_objects()
        {
            var wf = new StatefulWorkflow <ITest>("wf");

            wf.Yield(13);
            wf.Do((x, i) => { x.Ping((int)i["i"]); });

            var test = Mock.Of <ITest>(x => (int)x.GetStateId("wf") == 13);
            var mock = Mock.Get(test);

            wf.StartWithParams(test, new { i = 42 });
            mock.Verify(x => x.SetStateId("wf", null));
            mock.Verify(x => x.Ping((int)42));
        }
        public void it_can_use_params_at_any_step()
        {
            string secondStep = null;
            var wf = new StatefulWorkflow<ITest>("wf");
            wf.Yield(13);
            wf.Do((x, i) => { x.Ping((int)i["i"]); });
            wf.Do((x, opts) => secondStep = (string)opts["o"]);

            var test = Mock.Of<ITest>(x => (int)x.GetStateId("wf") == 13);
            var mock = Mock.Get(test);
            wf.StartWithParams(test, new { i = 42, o = "hello" });
            mock.Verify(x => x.SetStateId("wf", null));
            mock.Verify(x => x.Ping((int)42));
            secondStep.ShouldBe("hello");
        }
Exemple #4
0
        protected override IStatefulWorkflow <JobPosting> Define()
        {
            var createWorkgroup = Declare.Step();
            var createPosition  = Declare.Step();

            var wf = new StatefulWorkflow <JobPosting>();

            wf.Yield(JobPosting.CreationSteps.Begin);
            wf.When((post, dict) => (JobPosting.CreationSteps)dict["next"] == JobPosting.CreationSteps.CreatePosition)
            .Do(wfx => wfx.Do(x => DoThatThing(x)));

            wf.Define(createWorkgroup);
            wf.Yield(JobPosting.CreationSteps.CreateWorkgroup);

            wf.When(x => false);

            wf.Define(createPosition);
            wf.Yield(JobPosting.CreationSteps.CreatePosition);


            wf.Yield(JobPosting.CreationSteps.CreateJobPosting);
            wf.Yield(JobPosting.CreationSteps.Posted);
            return(wf);
        }
Exemple #5
0
        public void it_can_use_params_at_any_step()
        {
            string secondStep = null;
            var    wf         = new StatefulWorkflow <ITest>("wf");

            wf.Yield(13);
            wf.Do((x, i) => { x.Ping((int)i["i"]); });
            wf.Do((x, opts) => secondStep = (string)opts["o"]);

            var test = Mock.Of <ITest>(x => (int)x.GetStateId("wf") == 13);
            var mock = Mock.Get(test);

            wf.StartWithParams(test, new { i = 42, o = "hello" });
            mock.Verify(x => x.SetStateId("wf", null));
            mock.Verify(x => x.Ping((int)42));
            secondStep.ShouldBe("hello");
        }
        public void I_can_have_2_branches_to_the_same_yield()
        {
            var branch1 = Declare.Step();
            var wf = new StatefulWorkflow<StatefulObject>(2, gateway.Object);
            wf.Yield(1);
            wf.When(x => true).BranchTo(branch1);
            wf.Yield(2);
            wf.When(x => true).BranchTo(branch1);
            wf.Yield(3);
            wf.Define(branch1);
            wf.Yield(4);

            var transitions = wf.PossibleTransitions.ToList();
            transitions.Where(x => (int?)x.From == 1 && (int?)x.To == 4).Count().ShouldBe(1);
            transitions.Where(x => (int?)x.From == 2 && (int?)x.To == 4).Count().ShouldBe(1);
        }
        public void Operations_work_when_using_objects()
        {
            var wf = new StatefulWorkflow<ITest>("wf");
            wf.Yield(13);
            wf.Do((x, i) => { x.Ping((int)i["i"]); });

            var test = Mock.Of<ITest>(x => (int)x.GetStateId("wf") == 13);
            var mock = Mock.Get(test);
            wf.StartWithParams(test, new { i = 42 });
            mock.Verify(x => x.SetStateId("wf", null));
            mock.Verify(x => x.Ping((int)42));
        }