public TestFlowElement AddSwitchLink <T>(TestActivity sourceActivity, Dictionary <T, TestActivity> cases, List <int> hintsExecutingActivityIndex, TestActivity expressionActivity, params TestActivity[] defaultActivity) { TestFlowSwitch <T> flowSwitch = CreateSwitchElement <T>(sourceActivity, cases, hintsExecutingActivityIndex, defaultActivity, true) as TestFlowSwitch <T>; flowSwitch.ExpressionActivity = expressionActivity; return(AddTestFlowLink(flowSwitch)); }
/// <summary> /// Modify FlowSwitch's Case to point to a different activity /// </summary> /// <param name="flowSwitch">FlowSwitch to be updated</param> /// <param name="flowSwitchCase">case whose action to be updated</param> /// <param name="newCaseActivity">new activity to be executed in the given FlowSwitch Case</param> /// <param name="removeOldCaseNode">wehther we want to remove the old Case node from Flowchart</param> public void ChangeFlowSwitchCaseAction <T>(TestFlowSwitch <T> flowSwitch, T caseExpression, int caseIndex, TestActivity oldCaseActivity, TestActivity newCaseActivity, bool removeOldCaseNode = true) { TestFlowStep oldCaseNode = null; TestFlowStep newCaseNode = null; // remove old Case node from Flowchart if (removeOldCaseNode) { oldCaseNode = this.GetFlowStepContainingActionActivity(oldCaseActivity); if (oldCaseNode == null) { throw new ArgumentException("Failed to find the node corresponding to the given oldCaseActivity."); } this.Elements.Remove(oldCaseNode); } // add new Case node to Flowchart if (newCaseActivity != null) { newCaseNode = this.GetFlowStepContainingActionActivity(newCaseActivity); if (newCaseNode == null) { newCaseNode = new TestFlowStep(newCaseActivity); } this.AddTestFlowLink(newCaseNode); } // set new Case action flowSwitch.UpdateCase(caseExpression, caseIndex, newCaseNode); }
public TestFlowElement AddSwitchLink <T>(TestActivity sourceActivity, Dictionary <T, TestActivity> cases, List <int> hintsExecutingActivityIndex, Expression <Func <ActivityContext, T> > lambdaExpression, params TestActivity[] defaultActivity) { TestFlowSwitch <T> flowSwitch = CreateSwitchElement <T>(sourceActivity, cases, hintsExecutingActivityIndex, defaultActivity, true) as TestFlowSwitch <T>; flowSwitch.LambdaExpression = lambdaExpression; return(AddTestFlowLink(flowSwitch)); }
public TestFlowElement AddSwitchLink <T>(TestActivity sourceActivity, Dictionary <T, TestFlowElement> cases, List <int> hintsExecutingActivityIndex, T expression, params TestActivity[] defaultActivity) { TestFlowSwitch <T> flowSwitch = CreateSwitchElement <T>(sourceActivity, null, hintsExecutingActivityIndex, defaultActivity, true) as TestFlowSwitch <T>; flowSwitch.Expression = expression; foreach (KeyValuePair <T, TestFlowElement> flowCase in cases) { flowSwitch.AddCase(flowCase.Key, flowCase.Value); AddTestFlowLink(flowCase.Value); } return(AddTestFlowLink(flowSwitch)); }
/// <summary> /// Modify the FlowSwitch's Expression activity and its corresponding hint. /// </summary> public void ChangeFlowSwitchExpression <T>(TestFlowSwitch <T> flowSwitch, TestActivity newExpressionActivity, List <int> newHint) { flowSwitch.ExpressionActivity = newExpressionActivity; flowSwitch.SetHints(newHint); }
/// <summary> /// Modify the FlowSwitch's Expression and its corresponding hint. /// </summary> public void ChangeFlowSwitchExpression <T>(TestFlowSwitch <T> flowSwitch, T newExpression, List <int> newHint) { flowSwitch.Expression = newExpression; flowSwitch.SetHints(newHint); }
private TestFlowSwitchBase CreateSwitchElement <T>(TestActivity sourceActivity, Dictionary <T, TestActivity> cases, List <int> hintsExecutingActivityIndex, TestActivity[] defaultActivity, bool genericSwitch = false) { TestFlowStep flowStep = null; List <TestFlowStep> newAddedSteps = new List <TestFlowStep>(); TestFlowSwitchBase flowSwitch; flowSwitch = new TestFlowSwitch <T>(); flowSwitch.SetHints(hintsExecutingActivityIndex); if (sourceActivity != null) { flowStep = GetFlowStepContainingActionActivity(sourceActivity); if (flowStep == null) { flowStep = new TestFlowStep(sourceActivity); AddTestFlowLink(flowStep); } } if (cases != null) { foreach (KeyValuePair <T, TestActivity> flowCase in cases) { TestFlowStep targetStep = GetFlowStepContainingActionActivity(flowCase.Value); if (targetStep == null && flowCase.Value != null) { //Need this to find identical FlowSteps in the cases locally as they are not //added yet to the linked list if ((targetStep = FindMatchingCase(newAddedSteps, flowCase.Value.DisplayName)) == null) { targetStep = new TestFlowStep(flowCase.Value); newAddedSteps.Add(targetStep); } AddTestFlowLink(targetStep); } (flowSwitch as TestFlowSwitch <T>).AddCase(flowCase.Key, targetStep); } } if (defaultActivity != null && defaultActivity.Length != 0) { TestFlowStep defaultStep = GetFlowStepContainingActionActivity(defaultActivity[0]); if (defaultStep == null) { if ((defaultStep = FindMatchingCase(newAddedSteps, defaultActivity[0].DisplayName)) == null) { defaultStep = new TestFlowStep(defaultActivity[0]); } } (flowSwitch as TestFlowSwitch <T>).Default = defaultStep; AddTestFlowLink(defaultStep); } if (flowStep != null) { flowStep.NextElement = flowSwitch; } else { SetStartNode(flowSwitch); } return(flowSwitch); }