Пример #1
0
        public void AddBinding(IStepDefinitionBinding stepBinding)
        {
            try
            {
                var item = new BoundStepSuggestions <TNativeSuggestionItem>(stepBinding, nativeSuggestionItemFactory);

                var affectedSuggestions = new List <IBoundStepSuggestion <TNativeSuggestionItem> >(
                    boundStepSuggestions.GetRelatedItems(stepBinding.Regex).SelectMany(relatedItem => relatedItem.Suggestions).Where(s => s.Match(stepBinding, GetBindingCulture(s), true, BindingMatchService)));
                affectedSuggestions.AddRange(notMatchingSteps[item.StepDefinitionType].Suggestions.Where(s => s.Match(stepBinding, GetBindingCulture(s), true, BindingMatchService)));

                foreach (var affectedSuggestion in affectedSuggestions)
                {
                    RemoveBoundStepSuggestion(affectedSuggestion);
                }

                boundStepSuggestions.Add(item);

                foreach (var affectedSuggestion in affectedSuggestions)
                {
                    AddStepSuggestion(affectedSuggestion);
                }
            }
            catch (Exception ex)
            {
                projectScope.Tracer.Trace("Error while adding step definition binding: " + ex, GetType().Name);
                throw;
            }
        }
Пример #2
0
        public void AddBinding(StepBinding stepBinding)
        {
            var item = new BoundStepSuggestions <TNativeSuggestionItem>(stepBinding, nativeSuggestionItemFactory);

            var affectedSuggestions = new List <IBoundStepSuggestion <TNativeSuggestionItem> >(
                boundStepSuggestions.GetRelatedItems(stepBinding.Regex).SelectMany(relatedItem => relatedItem.Suggestions).Where(s => s.Match(stepBinding, true, BindingMatchService)));

            affectedSuggestions.AddRange(notMatchingSteps[item.BindingType].Suggestions.Where(s => s.Match(stepBinding, true, BindingMatchService)));

            foreach (var affectedSuggestion in affectedSuggestions)
            {
                RemoveBoundStepSuggestion(affectedSuggestion);
            }

            boundStepSuggestions.Add(item);

            foreach (var affectedSuggestion in affectedSuggestions)
            {
                AddStepSuggestion(affectedSuggestion);
            }
        }