예제 #1
0
파일: FunctionScope.cs 프로젝트: krus/PTVS
        public override IEnumerable <KeyValuePair <string, VariableDef> > GetAllMergedVariables()
        {
            if (this != Function.AnalysisUnit.Scope)
            {
                // Many scopes reference one FunctionInfo, which references one
                // FunctionAnalysisUnit which references one scope. Since we
                // are not that scope, we won't look at _allCalls for other
                // variables.
                return(Variables);
            }

            var scopes = new HashSet <InterpreterScope>();
            var result = Variables.AsEnumerable();

            if (Function._allCalls != null)
            {
                foreach (var callUnit in Function._allCalls.Values)
                {
                    scopes.Add(callUnit.Scope);
                }
                scopes.Remove(this);
                foreach (var scope in scopes)
                {
                    result = result.Concat(scope.GetAllMergedVariables());
                }
            }
            return(result);
        }
예제 #2
0
        public ScriptRunResults RunScript()
        {
            // navigate to starting page
            setUrl(WebDriver, Script.StartingUrl);

            Results.StartingUrl = Script.StartingUrl;

            // ready to start start processing the steps
            foreach (var step in Script.Steps)
            {
                // if this step is a reference, the process that nested script
                if (step.EmbeddedScript != null)
                {
                    // run the other script now
                    var rs = new ScriptRunner(WebDriver, step.EmbeddedScript, Variables);
                    step.EmbeddedScript.Logger = Script.Logger;
                    var scriptResult = rs.RunScript();

                    // merge results into current set
                    foreach (var sr in scriptResult.StepResults)
                    {
                        Results.StepResults.Add(sr);
                    }

                    // merge variables into result
                    foreach (var v in scriptResult.Variables)
                    {
                        Results.Variables.Add(v.Key, v.Value);
                    }
                }
                else
                {
                    // run this step
                    var result = processStep(step);
                    Results.StepResults.Add(result);

                    // save to results
                    foreach (var v in Variables.AsEnumerable())
                    {
                        if (Results.Variables.ContainsKey(v.Key))
                        {
                            Results.Variables[v.Key] = v.Value;
                        }
                        else
                        {
                            Results.Variables.Add(v.Key, v.Value);
                        }
                    }

                    // if an expectation failed, then optionally don't continue running
                    if (Script.ContinueOnFailedExpectations && (result.MetExpectation.HasValue && !result.MetExpectation.Value))
                    {
                        break;
                    }
                }
            }

            return(Results);
        }