Esempio n. 1
0
 protected override void CacheMetadata(NativeActivityMetadata metadata)
 {
     metadata.AddImplementationVariable(outputText);
     this.output = new WriteLine { Text = new InArgument<string>(outputText) };
     metadata.AddImplementationChild(this.output);
     metadata.SetArgumentsCollection(metadata.GetArgumentsWithReflection());
 }
        public void Root_MustBeSetToRootActivity()
        {
            WriteLine writeLine = new WriteLine();

            var testee = new RootActivityParameter(writeLine);

            testee.Root.Should().BeSameAs(writeLine);
        }
        public void SetInstance_MustInjectWithWorkflowDefinition()
        {
            var activity = new WriteLine();
            WorkflowInvoker invoker = this.SetupWorkflowInvoker(activity);

            invoker.Invoke();

            this.activityInjector.Verify(injector => injector.Inject(activity));
        }
        public void CanProcess_WithConstructor_MustPassActivityToCanProcessDelegate()
        {
            Activity activity = null;
            var writeLine = new WriteLine();

            var testee = CreateTestee((a, r) => { activity = a; return false; }, (a, r) => { });

            testee.CanProcess(writeLine, new Sequence());
            
            activity.Should().BeSameAs(writeLine);
        }
        private static void CreateFlowchartUpdateMap()
        {
            ActivityBuilder wf = StartUpdate("FlowchartNumberGuessWorkflow.xaml");

            // Get a reference to the root Flowchart activity.
            Flowchart fc = wf.Implementation as Flowchart;

            // Update the Text of the two WriteLine activities that write the
            // results of the user's guess. They are contained in the workflow as the
            // True and False action of the "Guess < Target" FlowDecision, which is
            // Nodes[4].
            FlowDecision guessLow = fc.Nodes[4] as FlowDecision;

            // Update the "too low" message.
            FlowStep trueStep = guessLow.True as FlowStep;
            WriteLine tooLow = trueStep.Action as WriteLine;
            tooLow.Text = new CSharpValue<string>("Guess.ToString() + \" is too low.\"");

            // Update the "too high" message.
            FlowStep falseStep = guessLow.False as FlowStep;
            WriteLine tooHigh = falseStep.Action as WriteLine;
            tooHigh.Text = new CSharpValue<string>("Guess.ToString() + \" is too high.\"");

            // Add the new WriteLine that displays the closing message.
            WriteLine wl = new WriteLine
            {
                Text = new CSharpValue<string>("Guess.ToString() + \" is correct. You guessed it in \" + Turns.ToString() + \" turns.\"")
            };

            // Create a FlowStep to hold the WriteLine.
            FlowStep closingStep = new FlowStep
            {
                Action = wl
            };

            // Add this new FlowStep to the True action of the
            // "Guess == Guess" FlowDecision
            FlowDecision guessCorrect = fc.Nodes[3] as FlowDecision;
            guessCorrect.True = closingStep;

            // Add the new FlowStep to the Nodes collection.
            // If closingStep was replacing an existing node then
            // we would need to remove that Step from the collection.
            // In this example there was no existing True step to remove.
            fc.Nodes.Add(closingStep);

            // Create the update map.
            CreateUpdateMaps(wf, "FlowchartNumberGuessWorkflow.map");

            //  Save the updated workflow definition.
            SaveUpdatedDefinition(wf, "FlowchartNumberGuessWorkflow_du.xaml");
        }
        private static void CreateSequentialUpdateMap()
        {
            ActivityBuilder wf = StartUpdate("SequentialNumberGuessWorkflow.xaml");

            // Get a reference to the root activity in the workflow.
            Sequence rootSequence = wf.Implementation as Sequence;

            // Update the Text of the two WriteLine activities that write the
            // results of the user's guess. They are contained in the workflow as the
            // Then and Else action of the "Guess < Target" If activity.
            // Sequence[1]->DoWhile->Body->Sequence[2]->If->Then->If
            DoWhile gameLoop = rootSequence.Activities[1] as DoWhile;
            Sequence gameBody = gameLoop.Body as Sequence;
            If guessCorrect = gameBody.Activities[2] as If;
            If guessLow = guessCorrect.Then as If;
            WriteLine tooLow = guessLow.Then as WriteLine;
            tooLow.Text = new CSharpValue<string>("Guess.ToString() + \" is too low.\"");
            WriteLine tooHigh = guessLow.Else as WriteLine;
            tooHigh.Text = new CSharpValue<string>("Guess.ToString() + \" is too high.\"");

            // Add the new WriteLine that displays the closing message.
            WriteLine wl = new WriteLine
            {
                Text = new CSharpValue<string>("Guess.ToString() + \" is correct. You guessed it in \" + Turns.ToString() + \" turns.\"")
            };

            // Insert it as the third activity in the root sequence
            rootSequence.Activities.Insert(2, wl);

            // Create the update map.
            CreateUpdateMaps(wf, "SequentialNumberGuessWorkflow.map");

            // Save the updated workflow definition.
            SaveUpdatedDefinition(wf, "SequentialNumberGuessWorkflow_du.xaml");
        }
        private static void CreateStateMachineUpdateMap()
        {
            ActivityBuilder wf = StartUpdate("StateMachineNumberGuessWorkflow.xaml");

            // Get a reference to the root StateMachine activity.
            StateMachine sm = wf.Implementation as StateMachine;

            // Update the Text of the two WriteLine activities that write the
            // results of the user's guess. They are contained in the workflow as the
            // Then and Else action of the If activity in sm.States[1].Transitions[1].Action.
            If guessLow = sm.States[1].Transitions[1].Action as If;

            // Update the "too low" message.
            WriteLine tooLow = guessLow.Then as WriteLine;
            tooLow.Text = new CSharpValue<string>("Guess.ToString() + \" is too low.\"");

            // Update the "too high" message.
            WriteLine tooHigh = guessLow.Else as WriteLine;
            tooHigh.Text = new CSharpValue<string>("Guess.ToString() + \" is too high.\"");

            // Create the new WriteLine that displays the closing message.
            WriteLine wl = new WriteLine
            {
                Text = new CSharpValue<string>("Guess.ToString() + \" is correct. You guessed it in \" + Turns.ToString() + \" turns.\"")
            };

            // Add it as the Action for the Guess Correct transition. The Guess Correct
            // transition is the first transition of States[1]. The transitions are listed
            // at the bottom of the State activity designer.
            sm.States[1].Transitions[0].Action = wl;

            // Create the update map.
            CreateUpdateMaps(wf, "StateMachineNumberGuessWorkflow.map");

            // Save the updated workflow definition.
            SaveUpdatedDefinition(wf, "StateMachineNumberGuessWorkflow_du.xaml");
        }