コード例 #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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }