public StepScope Copy() { StepScope copy = new StepScope(ScopeName, ClassName, CacheKey, RootBranch); copy.VariableList.AddRange(VariableList); return(copy); }
private void zRemoveCurrentScope() { m_ScopeList.Remove(m_CurrentScope.ScopeName); m_ScopeDictionary.Remove(m_CurrentScope.ScopeName); m_CurrentScope.VariableList.Clear(); m_CurrentScope.RootBranch = null; m_CurrentScope = m_ScopeList.Count > 0 ? m_ScopeDictionary[m_ScopeList.Last()] : null; }
private string zResolveCacheKeyFromScopeCacheList(StepScope scope, string variableNamePart) { List <StateVariableInfo> scopeCache = m_ElementSetVariableListCache[scope.CacheKey]; foreach (StateVariableInfo scopeCacheVariable in scopeCache) { string tmpScopeNamePart, tmpVariableNamePart; DataUtils.ParseStateVariableName(scope.ScopeName, scopeCacheVariable.StateVariableName, out tmpScopeNamePart, out tmpVariableNamePart); if (tmpVariableNamePart == variableNamePart) { return(scopeCacheVariable.StateVariableName); } } return(null); }
private Scope ParseScope(StepScope bindingScope) { if (bindingScope == null) { return(null); } return(new Scope { FeatureTitle = bindingScope.FeatureTitle, ScenarioTitle = bindingScope.ScenarioTitle, Tag = string.IsNullOrWhiteSpace(bindingScope.Tag) ? null : _tagExpressionParser.Parse(bindingScope.Tag) }); }
public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan) { ColorizeKeywordLine(keyword, stepSpan, classifications.StepText); if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock)) { var matches = placeholderRe.Matches(text); foreach (Match match in matches) { ColorizeLinePart(match.Value, stepSpan, classifications.Placeholder); } } var editorLine = stepSpan.StartPosition.Line; var tags = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct(); var stepScope = new StepScope(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray()); currentStep = new GherkinStep((BindingType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepScope, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine); CurrentFileBlockBuilder.Steps.Add(currentStep); }
private void zAddVariablesToScopeFromDatabaseStep(DatabaseStep databaseStep) { foreach (OutputParameterMap parameterMap in databaseStep.OutputParameterMapping) { zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(parameterMap.StateVariable, DataType.String, parameterMap.PersistenceMode)); //TODO: get actual datatype } if (databaseStep.ResultMapping is ScalarResultMapping) { ScalarResultMapping scalarResultMapping = (ScalarResultMapping)databaseStep.ResultMapping; zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(scalarResultMapping.StateVariable, DataType.String, scalarResultMapping.PersistenceMode)); //TODO: get actual datatype } if (databaseStep.ResultMapping is TableResultMapping) { TableResultMapping tableResultMapping = (TableResultMapping)databaseStep.ResultMapping; StepScope tempScopeForTableResults = null; if (tableResultMapping.ObjectSetClassName != null && tableResultMapping.ObjectSetListName != null) { zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(tableResultMapping.ObjectSetListName, DataType.List, tableResultMapping.PersistenceMode)); string tempScopeCacheKey = zGetCacheKey(m_CurrentScope.ScopeName, tableResultMapping.ObjectSetListName); tempScopeForTableResults = new StepScope(Guid.NewGuid().ToString(), tableResultMapping.ObjectSetClassName, tempScopeCacheKey, null); zSetCurrentScope(tempScopeForTableResults); } foreach (TableResultMap tableResultMap in tableResultMapping.TableMapping) { zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(tableResultMap.StateVariable, DataType.String, tableResultMapping.PersistenceMode)); //TODO: get actual datatype } if (tempScopeForTableResults != null) { zRemoveCurrentScope(); } } }
protected bool Equals(StepScope other) { return(string.Equals(Tag, other.Tag) && string.Equals(FeatureTitle, other.FeatureTitle) && string.Equals(ScenarioTitle, other.ScenarioTitle)); }
private StepDefinition CreateStepDefinition(string regex = null, string type = null, string sourceLocation = null, StepScope scope = null, string paramTypes = null, string method = null, string expression = null, string error = null) { return(new StepDefinition { Method = method ?? "M1", Type = type ?? "Given", Regex = regex ?? "regex", SourceLocation = sourceLocation, Scope = scope, ParamTypes = paramTypes, Expression = expression, Error = error }); }
public GherkinStep(BindingType bindingType, StepDefinitionKeyword stepDefinitionKeyword, string stepText, StepScope stepScope, string keyword, int blockRelativeLine) : base(bindingType, stepDefinitionKeyword, keyword, stepText, stepScope) { BlockRelativeLine = blockRelativeLine; BindingStatus = BindingStatus.UnknownBindingStatus; }
public StepInstance(ScenarioStep step, StepScope stepScope, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory, int level = 1) : base((BindingType)step.ScenarioBlock, (StepDefinitionKeyword)step.StepKeyword, step.Keyword, step.Text, stepScope) { this.NativeSuggestionItem = nativeSuggestionItemFactory.Create(step.Text, GetInsertionText(step), level, BindingType.ToString().Substring(0, 1), this); }
private void zSetCurrentScope(StepScope newScope) { m_CurrentScope = newScope; m_ScopeDictionary.Add(newScope.ScopeName, newScope); m_ScopeList.Add(newScope.ScopeName); }
/// <summary> /// Main sequence analysis loop, or an "Analysis Pass". This method "passes" through the sequence step by step, /// keeps track of the sequence structurally (scope list, scope dictionary), /// and fires delegates for each step and for completion. /// </summary> /// <param name="sequence"></param> /// <param name="onStepScope"></param> /// <param name="onSequenceComplete"></param> private void zAnalyzeSequence(List <Step> sequence, Func <Step, bool> onStepScope, Action onSequenceComplete) { //Make sure this SequenceAnalyzer is not being used by another thread. It is not thread safe! All concurrent usage must be done on separate instances. if (m_ExecutionStack != null) { throw new InvalidOperationException("A zAnalyzeSequence call is already in progress. If you need to use this method concurrently, use a separate SequenceAnalyzer instance for each concurrent call."); } try { if (sequence.Count > 0) { m_ExecutionStack = new ExecutionStack(); m_ExecutionStack.BranchEnded += m_ExecutionStack_BranchEnded; m_ExecutionStack.SetSequence(sequence); zSetCurrentScope(new StepScope(DataScope.RootScopeName, DataScope.RootScopeName, null, m_ExecutionStack.CurrentBranch)); do { if (onStepScope != null && !onStepScope(m_ExecutionStack.CurrentStep)) { break; } if (m_ExecutionStack.CurrentStep is GetValueStep) { GetValueStep getValueStep = (GetValueStep)m_ExecutionStack.CurrentStep; zAddVariableToScopeFromGetValueStep(getValueStep); } if (m_ExecutionStack.CurrentStep is DatabaseStep) { DatabaseStep databaseStep = (DatabaseStep)m_ExecutionStack.CurrentStep; zAddVariablesToScopeFromDatabaseStep(databaseStep); } if (m_ExecutionStack.CurrentStep is GroupStep) { GroupStep groupStep = (GroupStep)m_ExecutionStack.CurrentStep; if (groupStep.Steps.Count > 0) { m_ExecutionStack.SetNewBranch(groupStep.Steps); } if (groupStep.Iteration is ObjectSetIteration && groupStep.Iteration.IsSetIteration) { ObjectSetIteration objectSetIteration = (ObjectSetIteration)groupStep.Iteration; if (objectSetIteration is ElementSetIteration) { ElementSetIteration elementSetIteration = (ElementSetIteration)objectSetIteration; zAddVariableToScopeFromElementSetIteration(elementSetIteration); } if (groupStep.Steps.Count > 0) { string newScopeCacheKey = zGetCacheKey(m_CurrentScope.ScopeName, objectSetIteration.ObjectSetListName); StepScope newScope = new StepScope(objectSetIteration.ObjectSetScopeName, objectSetIteration.ObjectSetClassName, newScopeCacheKey, m_ExecutionStack.PendingBranch); if (objectSetIteration is DataSetIteration) { List <StateVariableInfo> cacheList; if (newScope.CacheKey != null && m_ElementSetVariableListCache.TryGetValue(newScope.CacheKey, out cacheList)) { foreach (StateVariableInfo cachedVariable in cacheList) { if (newScope.ClassName == null || DataUtils.GetVariableNameScope(cachedVariable.StateVariableName) == newScope.ClassName) { StateVariableInfo variableForNewScope = zRescopeVariable(cachedVariable, objectSetIteration.ObjectSetScopeName); if (!newScope.VariableList.Contains(variableForNewScope)) { newScope.VariableList.Add(variableForNewScope); } } } } } zSetCurrentScope(newScope); } } } } while (m_ExecutionStack.MoveNext()); } if (onSequenceComplete != null) { onSequenceComplete(); } } catch (Exception ex) { throw ex; } finally { zCleanup(); } }
public StepInstanceTemplate(ScenarioStep scenarioStep, ScenarioOutline scenarioOutline, StepScope stepScope, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory) { BindingType = (BindingType)scenarioStep.ScenarioBlock; NativeSuggestionItem = nativeSuggestionItemFactory.Create(scenarioStep.Text, StepInstance <TNativeSuggestionItem> .GetInsertionText(scenarioStep), 1, BindingType.ToString().Substring(0, 1) + "-t", this); instances = new StepSuggestionList <TNativeSuggestionItem>(nativeSuggestionItemFactory); AddInstances(scenarioStep, scenarioOutline, stepScope, nativeSuggestionItemFactory); var match = paramRe.Match(scenarioStep.Text); StepPrefix = match.Success ? scenarioStep.Text.Substring(0, match.Index) : scenarioStep.Text; }
private void AddInstances(ScenarioStep scenarioStep, ScenarioOutline scenarioOutline, StepScope stepScope, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory) { foreach (var exampleSet in scenarioOutline.Examples.ExampleSets) { foreach (var row in exampleSet.Table.Body) { var replacedText = paramRe.Replace(scenarioStep.Text, match => { string param = match.Groups["param"].Value; int headerIndex = Array.FindIndex(exampleSet.Table.Header.Cells, c => c.Value.Equals(param)); if (headerIndex < 0) { return(match.Value); } return(row.Cells[headerIndex].Value); }); var newStep = scenarioStep.Clone(); newStep.Text = replacedText; instances.Add(new StepInstance <TNativeSuggestionItem>(newStep, stepScope, nativeSuggestionItemFactory, 2) { ParentTemplate = this }); } } }