/// <summary> /// Creates the ConditionLookup which is of the format source -> {target -> CondInfo} /// Populates the DependencyGraph which is of the format target > {source}. /// </summary> /// <returns> ConditionLookup. </returns> private Dictionary <int, Dictionary <int, CondInfo> > CreateConditionLookupAndPopulateDependencyGraph() { // Get list of the conditions that are on the execution flow ConditionFactory cf = this.TestSet.ConditionFactory as ConditionFactory; List conds = cf.NewList(string.Empty); Dictionary <int, Dictionary <int, CondInfo> > conditionLookup = new Dictionary <int, Dictionary <int, CondInfo> >(); // Loop through the list of conditions to populate conditions list & create a dependency matrix // source -> {target -> CondInfo} // target -> {source} foreach (ICondition c in conds) { int source = int.Parse($"{c.Source}"); int target = int.Parse($"{c.Target}"); int condType = int.Parse(c.Value.ToString()); // only add condition if both source and target is in our dictionary // there are phantom conditions recorded =.= if (this.testCaseDict.ContainsKey(source) && this.testCaseDict.ContainsKey(target)) { // Console.WriteLine("{0} : [{1} -> {2}]", c.ID, this.testCaseDict[source].Name, this.testCaseDict[target].Name); // Populating Dependency Graph if (this.testCaseCondDependencyGraph.ContainsKey(target)) { this.testCaseCondDependencyGraph[target].Add(source); } else { this.testCaseCondDependencyGraph[target] = new HashSet <int>() { source }; } if (conditionLookup.ContainsKey(source)) { conditionLookup[source].Add(target, new CondInfo() { CondType = condType, CondID = int.Parse($"{c.ID}") }); } else { conditionLookup[source] = new Dictionary <int, CondInfo> { { target, new CondInfo() { CondType = condType, CondID = int.Parse($"{c.ID}"), } }, }; } } } return(conditionLookup); }