/// <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 AddLink(TestActivity sourceActivity, TestActivity targetActivity) { //Search in the elements collection if the flowstep exists and just needs to be //connected to next element TestFlowStep sourceStep = GetFlowStepContainingActionActivity(sourceActivity); TestFlowStep targetStep = GetFlowStepContainingActionActivity(targetActivity); if (sourceStep == null) { sourceStep = new TestFlowStep(sourceActivity); SetStartNode(sourceStep); AddTestFlowLink(sourceStep); } if (targetStep == null) { targetStep = new TestFlowStep(targetActivity); } sourceStep.NextElement = targetStep; AddTestFlowLink(targetStep); //We need to return the source step since the IsFaulting has to be set in case //of fault return(sourceStep); }
public TestFlowElement AddStartLink(TestActivity targetActivity) { TestFlowStep flowStep = new TestFlowStep(targetActivity); SetStartNode(flowStep); return(AddTestFlowLink(flowStep)); }
public TestFlowElement AddConditionalLink(TestActivity sourceActivity, TestFlowConditional flowConditional, TestActivity trueActivity, TestActivity falseActivity) { if (sourceActivity != null) { TestFlowStep flowStep = GetFlowStepContainingActionActivity(sourceActivity); if (flowStep == null) { flowStep = new TestFlowStep(sourceActivity) { NextElement = flowConditional }; AddTestFlowLink(flowStep); SetStartNode(flowStep); } else { flowStep.NextElement = flowConditional; } } AddTestFlowLink(flowConditional); if (trueActivity != null) { //For loops we need to check if the element already exists with the target activity TestFlowStep trueStep = GetFlowStepContainingActionActivity(trueActivity); if (trueStep != null) { flowConditional.TrueAction = trueStep; } else { flowConditional.TrueAction = new TestFlowStep(trueActivity); } AddTestFlowLink(flowConditional.TrueAction); } if (falseActivity != null) { //For loops we need to check if the element already exists with the target activity TestFlowStep falseStep = GetFlowStepContainingActionActivity(falseActivity); if (falseStep != null) { flowConditional.FalseAction = falseStep; } else { flowConditional.FalseAction = new TestFlowStep(falseActivity); } AddTestFlowLink(flowConditional.FalseAction); } if (_startElement == null) { SetStartNode(flowConditional); AddTestFlowLink(flowConditional); } return(flowConditional); }
public void AddNullCase(TestActivity activity) { TestFlowStep step = null; FlowNode node = null; if (activity != null) { step = new TestFlowStep(activity); node = step.GetProductElement(); } (this.productFlowSwitch as FlowSwitch <T>).Cases.Add(default(T), node); this.caseElements.Add(step); }
/// <summary> /// Modify the FlowStep's Next to point to a different node /// </summary> /// <param name="flowStep">FlowStep to be updated</param> /// <param name="newNextActivity">new activity to be executed next</param> /// <param name="removeOldNextNode">wehther we want to remove the old Next node from Flowchart</param> public void ChangeFlowStepNextNode(TestFlowStep flowStep, TestActivity newNextActivity, bool removeOldNextNode = true) { TestFlowStep newNextNode = null; if (newNextActivity != null) { newNextNode = this.GetFlowStepContainingActionActivity(newNextActivity); if (newNextNode == null) { newNextNode = new TestFlowStep(newNextActivity); } } this.ChangeFlowStepNextNode(flowStep, newNextNode, removeOldNextNode); }
public TestFlowElement AddLink(TestActivity sourceActivity, TestFlowElement flowElement) { TestFlowStep sourceStep = GetFlowStepContainingActionActivity(sourceActivity); if (sourceStep == null) { sourceStep = new TestFlowStep(sourceActivity); SetStartNode(sourceStep); AddTestFlowLink(sourceStep); } sourceStep.NextElement = flowElement; AddTestFlowLink(flowElement); return(sourceStep); }
/// <summary> /// Modify the FlowStep's Next to point to a different node. /// /// This function is useful when we try to swap nodes because GetFlowStepContainingActionActivity() /// use the GetNextElement() to loop through all elements, as a result, it won't be able to loop /// through all the this.Elements in the middle of swapping. /// </summary> /// <param name="flowStep">FlowStep to be updated</param> /// <param name="newNextNode">new node to be executed next</param> /// <param name="removeOldNextNode">wehther we want to remove the old Next node from Flowchart</param> public void ChangeFlowStepNextNode(TestFlowStep flowStep, TestFlowElement newNextNode, bool removeOldNextNode = true) { // remove old Next node from Flowchart if (removeOldNextNode) { this.Elements.Remove(flowStep.NextElement); } // add new Next node to Flowchart if (newNextNode != null) { this.AddTestFlowLink(newNextNode); } // set new Next node flowStep.NextElement = newNextNode; }
/// <summary> /// Modify the FlowDecision's True or False path to point to a different node /// </summary> /// <param name="flowConditional">FlowDecision to be updated</param> /// <param name="changeTrueAction">true if TrueAction to be changed, false if FalseAction to be changed</param> /// <param name="newAction">new activity to be executed on the specified FlowDecision's path</param> /// <param name="removeOldNode">wehther we want to remove the old node from Flowchart</param> public void ChangeFlowDecisionAction(TestFlowConditional flowConditional, bool changeTrueAction, TestActivity newAction, bool removeOldNode = true) { // remove old node from Flowchart if (removeOldNode) { if (changeTrueAction) { this.Elements.Remove(flowConditional.TrueAction); } else { this.Elements.Remove(flowConditional.FalseAction); } } // add new node to Flowchart TestFlowStep newNode = null; if (newAction != null) { newNode = this.GetFlowStepContainingActionActivity(newAction); if (newNode == null) { newNode = new TestFlowStep(newAction); } this.AddTestFlowLink(newNode); } // set new Action if (changeTrueAction) { flowConditional.TrueAction = newNode; } else { flowConditional.FalseAction = newNode; } }
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); }